栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3046 Random or Shuffle II

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3046 Random or Shuffle II

#include<stdio.h>#include<algorithm>#include<iostream>#include<map>#include<string.h>using namespace std;map<string,int> name;const int maxn=10200;int now,n,ttt;int use[maxn],a[maxn],here[maxn];bool bo[maxn];int get(string &s){if ( name.find(s)==name.end() )name[s]=++now;return name[s];}bool check(int sta){int mode=1;int num=0;ttt++;for (int i=sta;i<=n;i++){int t=a[i];if ( here[t]!=ttt ){here[t]=ttt;use[t]=0;}use[t]++;if ( use[t]==mode ){num++;if ( num==now ){mode++;num=0;}}elsereturn 0;}return 1;}int main(){string s;char ss[100];int t,mode,len,num;while ( scanf("%d",&n)!=EOF){now=0;memset(here,0,sizeof(here));bool ans=true;name.clear();getchar();for (int i=1;i<=n;i++){gets(ss);s = string(ss);a[i] = get(s);}memset(bo,0,sizeof(bo));ans=0;ttt++;for (int i=1;i<=n;i++)if ( !bo[a[i]] ){bo[a[i]]=1;if ( check(i) ){ans=1;break;}}else{if ( check(i) ) ans=1; break;}if ( ans )printf("Eithern");elseprintf("Randomn");}}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/381062.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号