문제 링크: https://www.acmicpc.net/problem/14174
14174번: Block Game
Farmer John is trying to teach his cows to read by giving them a set of N spelling boards typically used with preschoolers (1≤N≤100). Each board has a word and an image on each side. For example, one side might have the word 'cat' along with a picture of a
www.acmicpc.net
각 카드마다 앞면, 뒷면 모두를 표현하기 위해 필요한 알파벳 갯수를 세서 다 더함.
예시 >
2
aaa aab
bba aba
첫번째 카드에서는 3장의 a와 1장의 b가 필요하고
두번째 카드에서는 2장의 a와 2장의 b가 필요하므로
총 5장의 a와 3장의 b가 있으면 됨.
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
|
#include <bits/stdc++.h>
using namespace std;
int N, ans[200], tmp1[200], tmp2[200];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N;
while(N--) {
memset(tmp1, 0, sizeof(tmp1));
memset(tmp2, 0, sizeof(tmp2));
string s, t;
cin >> s >> t;
for(int j = 0; j < s.size(); j++)
tmp1[s[j]]++;
for(int j = 0; j < t.size(); j++)
tmp2[t[j]]++;
for(int j = 'a'; j <= 'z'; j++)
ans[j] += max(tmp1[j], tmp2[j]);
}
for(int i = 'a'; i <= 'z'; i++)
cout << ans[i] << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'USACO > Bronze' 카테고리의 다른 글
백준 14455 Don't Be Last! (USACO January 2017 Bronze 1번) (0) | 2020.02.28 |
---|---|
백준 14175 The Cow-Signal (USACO December 2016 Bronze 3번) (0) | 2020.02.28 |
백준 14173 Square Pasture (USACO December 2016 Bronze 1번) (0) | 2020.02.28 |
백준 12005 Diamond Collector (USACO US Open 2016 Bronze 1번) (0) | 2020.02.27 |
백준 12001 Load Balancing (USACO February 2016 Bronze 3번) (0) | 2020.02.27 |