#include#include #include #include #include #include #include #include #include #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; int has[10]; int ge[20][6] = {{1}, {1, 2}, {2, 3}, {3} ,{1, 4}, {1, 2, 4, 5}, {2, 3, 5, 6}, {3, 6} ,{4, 7}, {4, 5, 7, 8}, {5, 6, 8, 9}, {6, 9} ,{7}, {7, 8}, {8, 9}, {9}}; int cnt[20] = {1, 2, 2, 1, 2, 4, 4, 2, 2, 4, 4, 2, 1, 2, 2, 1}; set V[15]; int g[15][15], du[15]; int shu[20], in[15]; bool toposort() { mem(du, 0); for (int i = 1; i <= 9; i++) for (int j = 1; j <= 9; j++) if (g[i][j]) du[j]++; queue q; int tot = 0; for (int i = 1; i <= 9; i++) if (!du[i]) q.push(i); while(!q.empty()) { int u = q.front(); q.pop(); tot++; set ::iterator it; for (it = V[u].begin(); it != V[u].end(); it++) { int v = *it; du[v]--; if (!du[v]) q.push(v); } } if (tot == 9) return 1; return 0; } int main () { char str[20]; while(gets(str)) { if (str[0] == 'E') break; mem(has, 0); mem(g, 0); for (int i = 1; i <= 9; i++) V[i].clear(); for (int i = 0; i < 16; i++) { scanf("%d", shu + i); has[shu[i]] = 1; } int ok = 0; for (int i = 0; i < 16; i++) { int u = shu[i], l = cnt[i]; for (int j = 0; j < l; j++) { int v = ge[i][j]; if (v != u && has[v]) { V[v].insert(u); g[v][u] = 1; } if (v == u) ok++; } } if (ok == 16 && toposort()) puts("THESE WINDOWS ARE CLEAN"); else puts("THESE WINDOWS ARE BROKEN"); getchar(); gets(str); } return 0; }