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 |
1A,贴个代码#include <map> #include <set> #include <cmath> #include <stack> #include <queue> #include <vector> #include <cstdio> #include <string> #include <utility> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define eps 1e-8 #define randin srand((unsigned int)time(NULL)) #define input freopen("input.txt","r",stdin) #define debug(s) cout << "s = " << s << endl; #define outstars cout << "*************" << endl; const double PI = acos(-1.0); const int inf = 0x3f3f3f3f; const int INF = 0x7fffffff; typedef long long ll; string str; int mp[5][5]; int node[10][10]; int inde[10], outde[10], vis[10]; int edge[20][10] = { {0, 0}, {1, 1}, {2, 1, 2}, {2, 2, 3}, {1, 3}, {2, 1, 4}, {4, 1, 2, 4, 5}, {4, 2, 3, 5, 6}, {2, 3, 6}, {2, 4, 7}, {4, 4, 5, 7, 8}, {4, 5, 6, 8, 9}, {2, 6, 9}, {1, 7}, {2, 7, 8}, {2, 8, 9}, {1, 9} }; void init() { memset(node, 0, sizeof(node)); memset(inde, 0, sizeof(inde)); memset(outde, 0, sizeof(outde)); memset(vis, 0, sizeof(vis)); } int main() { //input; while (cin >> str) { init(); if (str == "ENDOFINPUT") break; for (int i = 1; i <= 4; i ++) { for (int j = 1; j <= 4; j ++) { scanf("%d", &mp[i][j]); int pos = (i - 1) * 4 + j; int tmp = mp[i][j]; for (int k = 1; k <= edge[pos][0]; k ++) { if (edge[pos][k] == tmp) continue; if (node[tmp][edge[pos][k]] == 0) { node[tmp][edge[pos][k]] = 1; outde[tmp] ++; inde[edge[pos][k]] ++; } } } } int cnt = 0; while (1) { bool flag = false; for (int i = 1; i <= 9; i ++) { if (inde[i] == 0 && !vis[i]) { cnt ++; vis[i] = 1; flag = true; for (int j = 1; j <= 9; j ++) { if (node[i][j]) { node[i][j] = 0; inde[j] --; } } } } if (flag == false) break; } if (cnt == 9) printf("THESE WINDOWS ARE CLEAN\n"); else printf("THESE WINDOWS ARE BROKEN\n"); cin >> str; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator