USACO/Bronze
백준 17029 Guess the Animal (USACO January 2019 Bronze 3번)
ssam..
2020. 3. 14. 03:17
문제 링크: 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
|