-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path327-c.cpp
More file actions
52 lines (51 loc) · 1.17 KB
/
327-c.cpp
File metadata and controls
52 lines (51 loc) · 1.17 KB
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
#include <bits/stdc++.h>
using namespace std;
int a[10][10];
bool m[10][10], n[10][10];
bool check(int x0, int x1, int y0, int y1)
{
bool checka[10];
memset(checka, 0, sizeof(checka));
for (int i = x0; i <= x1; i++)
{
for (int j = y0; j <= y1; j++)
{
if (checka[a[i][j]])
return 1;
checka[a[i][j]] = 1;
}
}
return 0;
}
int main()
{
bool flags1 = 0;
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= 9; j++)
{
cin >> a[i][j];
if (m[i][a[i][j]] || n[j][a[i][j]])
{
flags1 = 1;
}
m[i][a[i][j]] = n[j][a[i][j]] = 1;
}
}
if (flags1)
{
cout << "No" << endl;
system("pause");
return 0;
}
bool flags2 = check(1, 3, 1, 3) || check(1, 3, 4, 6) || check(1, 3, 7, 9) || check(4, 6, 1, 3) || check(4, 6, 4, 6) || check(4, 6, 7, 9) || check(7, 9, 1, 3) || check(7, 9, 4, 6) || check(7, 9, 7, 9);
if (flags2)
{
cout << "No" << endl;
system("pause");
return 0;
}
cout << "Yes" << endl;
system("pause");
return 0;
}