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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
| #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main() {
int n, u, v, m;
cin >> n >> u >> v >> m;
map<int, vector<P> > ma[2];
vector<vector<int> > a(n, vector<int>(n)), b(n, vector<int>(n));
rep(i, n) {
rep(j, n) {
cin >> a[i][j];
ma[0][a[i][j]].push_back(mp(i, j));
}
}
rep(i, n) {
rep(j, n) {
cin >> b[i][j];
ma[1][b[i][j]].push_back(mp(i, j));
}
}
vector<int> x(m);
rep(i, m) cin >> x[i];
if(n == 1) {
rep(i, m) {
int sum[2];
memset(sum, 0, sizeof(sum));
rep(j, 2) {
vector<P> res = ma[j][x[i]];
if(res.size() >= 1) sum[j]++;
}
bool f1 = (sum[0] >= u);
bool f2 = (sum[1] >= v);
if(f1 && f2) {
cout << "DRAW" << endl;
return 0;
} else if(f1) {
cout << "USAGI" << endl;
return 0;
} else if(f2) {
cout << "NEKO" << endl;
return 0;
}
}
cout << "DRAW" << endl;
return 0;
}
int cy[2][505], cx[2][505], cross[2][2];
memset(cy, 0, sizeof(cy));
memset(cx, 0, sizeof(cx));
memset(cross, 0, sizeof(cross));
rep(i, m) {
rep(j, 2) {
vector<P> res = ma[j][x[i]];
rep(k, res.size()) {
int f = res[k].first, s = res[k].second;
cy[j][f]++;
cx[j][s]++;
if(f == s) cross[j][0]++;
if(f == n - 1 - s) cross[j][1]++;
}
}
int sum[2];
memset(sum, 0, sizeof(sum));
rep(j, 2) {
rep(k, 2) {
sum[j] += (cross[j][k] == n);
}
}
rep(j, 2) {
rep(k, n) {
sum[j] += (cy[j][k] == n);
sum[j] += (cx[j][k] == n);
}
}
bool f1 = (sum[0] >= u), f2 = (sum[1] >= v);
if(f1 && f2) {
cout << "DRAW" << endl;
return 0;
} else if(f1) {
cout << "USAGI" << endl;
return 0;
} else if(f2) {
cout << "NEKO" << endl;
return 0;
}
}
cout << "DRAW" << endl;
return 0;
}
|