문제 링크: https://www.acmicpc.net/problem/14531
14531번: Bovine Genomics (Bronze)
The first line of input contains \(N\) and \(M\), both positive integers of size at most 100. The next \(N\) lines each contain a string of \(M\) characters; these describe the genomes of the spotty cows. The final \(N\) lines describe the genomes of the p
www.acmicpc.net
M개의 각각의 자리마다 spotty에 있었던 알파벳이 plain에는 없을때마다 답을 1씩 증가시키면 됨.
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
|
#include <bits/stdc++.h>
using namespace std;
int N, M, check[200];
char spotty[101][101], plain[101][101];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N >> M;
for(int i = 0; i < N; i++) for(int j = 0; j < M; j++)
cin >> spotty[i][j];
for(int i = 0; i < N; i++) for(int j = 0; j < M; j++)
cin >> plain[i][j];
int ans = 0;
for(int j = 0; j < M; j++) {
memset(check, 0, sizeof(check));
for(int i = 0; i < N; i++)
check[spotty[i][j]] = 1;
int flag = 1;
for(int i = 0; i < N; i++) {
if(check[plain[i][j]] != 0) {
flag = 0;
break;
}
}
if(flag) ans++;
}
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 15464 The Bovine Shuffle (USACO December 2017 Bronze 2번) (0) | 2020.03.03 |
---|---|
백준 15463 Blocked Billboard (USACO December 2017 Bronze 1번) (0) | 2020.03.03 |
백준 14530 The Lost Cow (USACO US Open 2017 Bronze 1번) (0) | 2020.03.01 |
백준 14469 소가 길을 건너간 이유 3 (USACO February 2017 Bronze 3번) (0) | 2020.03.01 |
백준 14468 소가 길을 건너간 이유 2 (USACO February 2017 Bronze 2번) (0) | 2020.02.29 |