Skip to content

Commit dad1b53

Browse files
committed
atcoder/abc157B
1 parent c04a9cc commit dad1b53

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

atcoder/abc157/B/main.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
vector<vector<int>> A(3, vector<int>(3, 0));
12+
vector<vector<bool>> C(3, vector<bool>(3, false));
13+
14+
auto const mark = [&](int n) {
15+
for (int i = 0; i < 3; ++i) {
16+
for (int j = 0; j < 3; ++j) {
17+
if (A[i][j] == n) {
18+
C[i][j] = true;
19+
}
20+
}
21+
}
22+
};
23+
auto const is_bingo = [&]() {
24+
bool bingo = false;
25+
for (int i = 0; i < 3; ++i) {
26+
bingo |= C[i][0] == true && C[i][0] == C[i][1] && C[i][0] == C[i][2];
27+
bingo |= C[0][i] == true && C[0][i] == C[1][i] && C[0][i] == C[2][i];
28+
}
29+
bingo |= C[0][0] == true && C[0][0] == C[1][1] && C[0][0] == C[2][2];
30+
bingo |= C[0][2] == true && C[0][2] == C[1][1] && C[0][2] == C[2][0];
31+
return bingo;
32+
};
33+
34+
for (int i = 0; i < 3; ++i) {
35+
for (int j = 0; j < 3; ++j) {
36+
cin >> A[i][j];
37+
}
38+
}
39+
40+
int N;
41+
cin >> N;
42+
for (int i = 0; i < N; ++i) {
43+
int b;
44+
cin >> b;
45+
mark(b);
46+
}
47+
48+
cout << (is_bingo() ? "Yes" : "No") << endl;
49+
50+
return 0;
51+
}

0 commit comments

Comments
 (0)