Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why TLE???#include<cstdio> #include<cstring> char s[100]; int p[100]; char team1[100]; char team2[100]; char team3[100]; int u,v,w; int main() { int i,k,k1,k2,k3,n,t,r; while(scanf("%d %d %d",&n,&t,&r)!=EOF) { if(n==0&&t==0&&r==0) break; scanf("%s",s); k=strlen(s); u=v=w=0; for(i=0;i<k;i++) { if(s[i]>='a'&&s[i]<='i') { p[i]=1; team1[u++]=s[i]; } else if(s[i]>='j'&&s[i]<='r') { p[i]=2; team2[v++]=s[i]; } else { p[i]=3; team3[w++]=s[i]; } } team1[u]=team2[v]=team3[w]='\0'; k1=u; k2=v; k3=w; u=-n; while(u<0) u+=k1; v=-t; while(v<0) v+=k2; w=-r; while(w<0) w+=k3; for(i=0;i<k;i++) { if(p[i]==1) { s[i]=team1[u]; u=(u+1)%k1; } else if(p[i]==2) { s[i]=team2[v]; v=(v+1)%k2; } else { s[i]=team3[w]; w=(w+1)%k3; } } s[k]='\0'; printf("%s\n",s); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator