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 |
抱着过不了的心态,提交了,居然AC,一脸懵逼#include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> char map[102][102]; char t_map[102][102]; char inputs[22]; int main() { int m,n; m = 0; n = 0; char temp; char str[200]; while (scanf("%c", &temp) !=EOF) { memset(map, ' ', sizeof(map)); int i = 0; int j = 0; m = n = 0; while (temp != '*') { if (temp == '\n'){ if (j > m) m = j; j = 0; i++; scanf("%c", &temp); continue; } map[i][j] = temp; j++; scanf("%c", &temp); } n = i; while (scanf("%s", str) && str[0]!= '*') { for (i = 0; i < n; ++i) { strcpy(t_map[i], map[i]); } for (int i = 0; i < n; ++i) { for (j = 0; j < m; ++j) { if (t_map[i][j] >= 'A' && t_map[i][j] <= 'Z') { char d = str[t_map[i][j] - 'A']; int dir = 0; //判断往哪个方向走 while (1) { if (j + 1 < m && t_map[i][j + 1] == '-') { t_map[i][j] = ' '; dir = 0; j += 1; while ( j< m && t_map[i][j] == '-') { t_map[i][j] = ' '; ++j; } } else if (j - 1 >= 0 && t_map[i][j - 1] == '-') { t_map[i][j] = ' '; dir = 0; j -= 1; while (j>=0 && t_map[i][j] == '-') { t_map[i][j] = ' '; --j; } } else if (i + 1 < m && t_map[i + 1][j] == '|') { t_map[i][j] = ' '; dir = 1; i += 1; while (i < m && t_map[i][j] == '|') { t_map[i][j] = ' '; ++i; } } else if (i >= 0 && t_map[i - 1][j] == '|') { t_map[i][j] = ' '; dir = 0; i -= 1; while (i >= 0 && t_map[i][j] == '|') { t_map[i][j] = ' '; i--; } } if (t_map[i][j] == ':') { t_map[i][j-1] = d; if (i + 2 < n && (t_map[i + 2][j-1] == '0' || t_map[i + 2][j-1] == '1')) { if (t_map[i + 1][j + 2] == ')') { d = t_map[i + 1][j + 2] = t_map[i + 2][j - 1] == t_map[i][j - 1] && t_map[i][j - 1] == '1' ? '1' : '0'; } else { d = t_map[i + 1][j + 2] = t_map[i + 2][j-1] == '1' || t_map[i][j-1] == '1' ? '1' : '0'; } i += 1; j += 2; } else if (i - 2 >= 0 && (t_map[i - 2][j-1] == '0' || t_map[i - 2][j-1] == '1')) { if (t_map[i - 1][j + 2] == ')') { d = t_map[i - 1][j + 2] = t_map[i - 2][j - 1] == t_map[i][j - 1] && t_map[i][j - 1] == '1' ? '1' : '0'; } else { d = t_map[i - 1][j + 2] = t_map[i - 2][j-1] == '1' || t_map[i][j-1] == '1' ? '1' : '0'; } i -= 1; j += 2; } if (t_map[i][j + 1] != '-' && t_map[i][j + 1] != 'o') { break; } else { j++; } } if (t_map[i][j] == 'o') { d = '0' + (d - '0' + 1) % 2; t_map[i][j] = '-'; j--; } if (t_map[i][j] == '?') { printf("%c\n", d); goto sss; } if (t_map[i][j + 1] == 'o') { d = '0' + (d - '0' + 1) % 2; t_map[i][j+1] = d; j--; } if (t_map[i][j + 1] == '?') { printf("%c\n", d); goto sss; } //meet + if (t_map[i][j] == '+') { t_map[i][j] = ' '; if (dir) { dir = 0; } else { dir = 1; } } } } } } sss: ; } scanf("%c", &temp); printf("\n"); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator