Atcode1

C++一点内容:

久违了,ACM
这次就再来刷一次吧

链接

Bingo

Time Limit: 2 sec / Memory Limit: 1024 MB

Score :
200
points

Problem Statement
We have a bingo card with a 3×3grid. The square at the i-th row from the top and the j-th column from the left contains the number Ai,j.
The MC will choose N numbers, b1,b2,⋯,bN
. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints
All values in input are integers.
1≤Ai,j≤100,
Ai1,j1≠Ai2,j2
((i1,j1)≠(i2,j2))
1≤N≤101≤bi≤100bi≠bj(i≠j)
Input
Input is given from Standard Input in the following format:

1
2
3
4
5
A11,A12,A13,A21,A22,A23,A31,A32,A33
N
b1

bN

Output

we will have a bingo, print Yes; otherwise, print No.```
1
2

`Sample Input 1 `

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

1
2
3
`Sample Output 1 `

```Yes

We will mark A11,A21,A22,A33, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

1
2
3
4
5
6
7
8
9
41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

1
2
3
We will mark nothing.

`Sample Input 3 `

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

1
2
`Sample Output 3 `
```Yes

We will mark all the squares.

题意
3*3的矩阵,先输入数字填满矩阵,然后输入N个数字,如果方阵里面有这些数字,就标记一下
如果标记的数字在一行或一列或对角线上面有3个的话,就输出Yes,否则输出No
注意看题!!!仔细看题!!!

题解:

写的有点麻烦了,,,

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
#include<bits/stdc++.h>
using namespace std;
const int maxx = 4;
int a[maxx][maxx];
int b[101];
int c, d, e, f, g, h, k, m;
map<int, int> mp;
int main()
{
int N, x;
for(int i = 0; i < 3; i ++)
{
for(int j = 0; j < 3; j ++)
{
cin >> a[i][j];
b[a[i][j]] = false;
mp[a[i][j]] ++;
}
}
cin >> N;
for(int i = 0; i < N; i ++)
{
cin >> x;
mp[x] ++;
if(mp[x] == 2) b[x] = true;
else b[x] = false;
}
for(int i = 0; i < 3; i ++)
{
for(int j = 0; j < 3; j ++)
{
if(i == 0 && b[a[i][j]])
c ++;
if(i == 1 && b[a[i][j]])
d ++;
if(i == 2 && b[a[i][j]])
e ++;
if(j == 0 && b[a[i][j]])
f ++;
if(j == 1 && b[a[i][j]])
g ++;
if(j == 2 && b[a[i][j]])
h ++;
if(j == i && b[a[i][j]])
k ++;
if(((i == 0 && j == 2) || (i == 1 && j == 1) || (i == 2 && j == 0)) && b[a[i][j]])
m ++;
}
}
if(c == 3 || d == 3 || e == 3 || f == 3 || g == 3 || h == 3 || k == 3 || m == 3) cout << "Yes" << '\n';
else cout << "No" << '\n';
return 0;
}

---------------- The End ----------------
0%