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
|
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a) (a).begin(),(a).end()
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void solve() {
// 8lines
vector<vector<int>> eight_lines(8);
// create yoko
REP(i,3) {
vector<int> line(3);
REP(j,3) {
int A;
cin >> A;
line[j] = A;
}
eight_lines[i] = line;
}
// 4,5,6 create
REP(i,3) {
vector<int> line(3);
REP(j,3) {
line[j] = eight_lines[j][i];
}
eight_lines[3+i] = line;
}
// 7,8 create
vector<int> seven_line(3);
seven_line[0] = eight_lines[0][0];
seven_line[1] = eight_lines[1][1];
seven_line[2] = eight_lines[2][2];
eight_lines[6] = seven_line;
vector<int> eight_line(3);
eight_line[0] = eight_lines[2][0];
eight_line[1] = eight_lines[1][1];
eight_line[2] = eight_lines[0][2];
eight_lines[7] = eight_line;
// test
for(const auto &lns: eight_lines) {
for (const auto &l: lns) {
cerr << l << " ";
}
cerr << endl;
}
vector<vector<bool>> is_opened(8,vector<bool>(3,false));
int N;
cin >> N;
REP(i,N) {
int b;
cin >> b;
REP(j,8) {
REP(k,3) {
if (eight_lines[j][k] == b) is_opened[j][k] = true;
}
}
}
REP(i,8) {
if (all_of(ALL(is_opened[i]),[](bool x){ return x; })) {
cerr << "opened " << i << endl;
cout << "Yes" << endl;
return;
}
}
cout << "No" << endl;
return;
}
int main() {
solve();
return 0;
}
|