-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocks.cpp
44 lines (41 loc) · 1.02 KB
/
blocks.cpp
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
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
int main() {
freopen("blocks.in", "r", stdin);
freopen("blocks.out", "w", stdout);
int N; cin >> N;
pair<string, string> words[N];
for (int i=0; i<N; i++) {
cin >> words[i].first >> words[i].second;
}
int alphabet[26] = {0};
for (const auto& board: words) {
int alp1[26] = {0};
int alp2[26] = {0};
for (char cha: board.first) {
alp1[cha - 'a']++;
}
for (char cha: board.second) {
alp2[cha - 'a']++;
}
for (int i=0; i<26; i++) {
if (alp1[i] > alp2[i]) {
alphabet[i] += alp1[i];
} else if (alp1[i] < alp2[i]) {
alphabet[i] += alp2[i];
} else {
alphabet[i] += alp1[i];
}
}
}
for (int i=0; i<26; i++) {
cout << alphabet[i] << endl;
}
}