-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path#P1654.cpp
54 lines (53 loc) · 1.34 KB
/
#P1654.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
#include <bits/stdc++.h>
using namespace std;
int a[9][9], n;
bool f()
{
bool xf[9];
for (int i = 0; i < 9; i++)
{
for (int m = 0; m < 9; m++)
xf[m] = false;
for (int j = 0; j < 9; j++)
if (xf[a[i][j] - 1] == true)
return false;
else
xf[a[i][j] - 1] = true;
for (int m = 0; m < 9; m++)
xf[m] = false;
for (int j = 0; j < 9; j++)
if (xf[a[j][i] - 1] == true)
return false;
else
xf[a[j][i] - 1] = true;
}
for (int m = 0; m < 9; m++)
xf[m] = false;
for (int i = 0; i <= 6; i += 3)
for (int j = 0; j <= 6; j += 3){
for (int m = 0; m < 9; m++)
xf[m] = false;
for (int x = 0; x < 3; x++)
for (int y = 0; y < 3; y++)
if (xf[a[i + x][j + y] - 1] == true)
return false;
else
xf[a[i + x][j + y] - 1] = true;
}
return true;
}
int main()
{
cin >> n;
while (n--)
{
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++)
cin >> a[i][j];
if (f())
cout << "Right" << endl;
else
cout << "Wrong" << endl;
}
return 0;
}