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 |
What's wrong with this code?? Why WA??#include <stdio.h> #include <map> using namespace std; #define MAX 202 int main() { int i , j , k , n , c[MAX] , d[MAX] , e[MAX][MAX]; char a[MAX] , b[MAX]; map<int, int> m; map<int, int>::iterator it; while(scanf("%d" ,&n) && n) { m.clear(); for(i = 0;i < n;i++) scanf("%d" ,&c[i]); int count = 0 ,t; for(i = 0;i < n;i++) { count = 1; e[i][0] = t = c[i]; for(j = 1;t != i + 1;j++) { count++; e[i][j] = t = c[t - 1]; } d[i] = count; m[count] = count; } long int num = 1; for(it = m.begin();it != m.end();it++) num *= it->second; while(scanf("%d" ,&k) && k) { k %= num; scanf("%c"); gets(a); for(i = 0;i < n;i++) b[i] = ' '; for(i = 0;a[i] != '\0';i++) b[((k % d[i] == 0) ? t = i : t = e[i][(k % d[i] - 1)] - 1 ,t)] = a[i]; puts(b); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator