题解 - [UVa 10887] Concatenation of Languages

题目链接

原始题面

题意简述

给出两个字符串集合 \(A,B\), 求 \(|\{a+b|a\in A,b\in B\}|\)

解题思路

std::set 水过即可

这题完全可以出的更难的

代码参考

Show code

UVA_10887view raw
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
/*
* @Author: Tifa
* @Description: From <https://github.com/Tiphereth-A/CP-archives>
* !!! ATTENEION: All the context below is licensed under a
* GNU Affero General Public License, Version 3.
* See <https://www.gnu.org/licenses/agpl-3.0.txt>.
*/
#include <bits/stdc++.h>
using namespace std;
string s1[1500], s2[1500];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
for (int kase = 1; kase <= t; ++kase) {
set<string> s;
int n, m;
cin >> n >> m;
getline(cin, s1[0]);
for (int i = 0; i < n; ++i) getline(cin, s1[i]);
for (int i = 0; i < m; ++i) getline(cin, s2[i]);
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j) s.insert(s1[i] + s2[j]);
cout << "Case " << kase << ": " << s.size() << endl;
}
return 0;
}