문제 링크: https://www.acmicpc.net/problem/17029
17029번: Guess the Animal
The first line of input contains the number of animals, $N$ ($2 \leq N \leq 100$). Each of the next $N$ lines describes an animal. The line starts with the animal name, then an integer $K$ ($1 \leq K \leq 100$), then $K$ characteristics of that animal. Ani
www.acmicpc.net
각각의 pair of animals 마다 두마리 모두 가지고 있는 특징의 갯수들의 최대값을 구해서 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
|
#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> c[101];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++) {
string name, character;
int k;
cin >> name >> k;
for(int j = 0; j < k; j++) {
cin >> character;
c[i].push_back(character);
}
}
int ans = 0;
for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) {
int cnt = 0;
for(int k = 0; k < c[i].size(); k++) for(int l = 0; l < c[j].size(); l++)
if(c[i][k] == c[j][l]) cnt++;
ans = max(ans, cnt);
}
cout << ans + 1 << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 17040 The Great Revegetation (USACO February 2019 Bronze 2번) (0) | 2020.03.14 |
---|---|
백준 17039 Sleepy Cow Herding (USACO February 2019 Bronze 1번) (0) | 2020.03.14 |
백준 17028 Sleepy Cow Sorting (USACO January 2019 Bronze 2번) (0) | 2020.03.13 |
백준 17027 Shell Game (USACO January 2019 Bronze 1번) (0) | 2020.03.13 |
백준 16770 The Bucket List (USACO December 2018 Bronze 2번) (0) | 2020.03.13 |