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 |
RE求助。。。这个程序打出来的表ac了。。不过用它跑就re了。。。求助。。。应该不是oj的问题。。。c++g++都re。。。求大牛#include <cstdio> #include <cstring> struct node { int num; node * next[6]; }; bool flag[5]; int cnt[5]; int d[10001] = {}; int main() { node *a; a->num = 0; for (int i = 0; i < 6; i++) a->next[i] = NULL; int j = 0, k, l, m, n; memset(cnt, 0, sizeof (cnt)); cnt[0] = 1; for (int i = 2; i <= 10000; i++) { if (a->next[j] != NULL) { a = a->next[j]; j = (j + 5) % 6; } node *tmp = new node; for (m = 0; m < 6; m++) tmp->next[m] = NULL; k = (j + 3) % 6; a->next[j] = tmp; tmp->next[k] = a; tmp ->next[(k + 5) % 6] = a->next[(j + 1) % 6]; tmp ->next[(k + 1) % 6] = a->next[(j + 5) % 6]; if (a->next[(j + 5) % 6] != NULL) a->next[(j + 5) % 6]->next[(j + 1) % 6] = tmp; if (a->next[(j + 1) % 6] != NULL) a->next[(j + 1) % 6]->next[(j + 5) % 6] = tmp; memset(flag, 0, sizeof (flag)); for (l = 0; l < 6; l++) if (tmp->next[l] != NULL) flag[tmp->next[l]->num] = 1; int col, ans = 1000000; for (l = 0; l < 5; l++) if (!flag[l] && ans > cnt[l]) { ans = cnt[l]; col = l; } tmp->num = col; d[i] = col; cnt[col]++; j = (j + 1) % 6; } int cas; scanf("%d", &cas); while (cas--) { scanf("%d", &n); printf("%d\n", d[n] + 1); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator