-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11110 - Equidivisions.cpp
89 lines (83 loc) · 2.78 KB
/
11110 - Equidivisions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/******************************************************************************
* ▄██████████▄ ▀█████████▄ ▀██████████▄ ▄████████████▄ ▄██████████▄ *
* ▀▀███ ███▀ ███ ███ ███ ▀██▄ ▀███▀ ▀███▀ █▀ ▄███▀ *
* ███ ███ ███ ██ ███ ███ ▄███▀ *
* ▄███▄▄▄██▀ ▄███▄▄▄██▀ ███ ██▀ ███ ███ ▄███▀ *
* ▀▀███▀▀▀██▄ ▀▀███▀▀▀██▄ ▄███▄▄▄▄▄██▀ ███ ███ ▄███▀ *
* ███ ███ ▀▀███▀▀▀▀▀██▄ ███ ███ ▄███▀ *
* ███ ███ ███ ███ ███ ▄███▄ ▄███▄ ▄███▀ ▄█ *
* ▄▄████▀ ▄█████████▀ ▄███ ███▄ ▀████████████▀ ▀██████████▀ *
* *
* *Don't limit your challenges, challenge your limits. *
******************************************************************************/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n,k,x,y,v[N][N];
bool vis[N][N], b, mark[N];
string str;
void dfs(int i, int j){
if(i < 1 or i > n or j < 1 or j > n or vis[i][j] or v[i][j] != k) return;
vis[i][j] = 1;
dfs(i-1,j);
dfs(i,j-1);
dfs(i+1,j);
dfs(i,j+1);
}
void init(){
while(cin >> n and n){
getline(cin,str);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
vis[i][j] = 1;
}
mark[i] = 1;
}
for(int i = 1; i < n; i++){
getline(cin,str);
istringstream iss(str);
while(iss >> x >> y){
v[x][y] = i;
vis[x][y] = 0;
}
}
k = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(vis[i][j]){
++k;
vis[i][j] = 0;
v[i][j] = n;
}
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(mark[v[i][j]]){
k = v[i][j];
dfs(i,j);
mark[v[i][j]] = 0;
}
}
}
b = 1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(!vis[i][j]){
b = 0;
}
}
}
if(b) printf("good\n");
else printf("wrong\n");
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
init();
return 0;
}