QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#139539 | #5499. Aliases | ammardab3an# | WA | 175ms | 5168kb | C++17 | 1.2kb | 2023-08-13 20:23:44 | 2023-08-13 20:23:46 |
Judging History
answer
#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
using namespace std;
const ll N = 1e6 + 10, MM = 1e9 + 7, MAX = 1e18;
int solve() {
int n; cin >> n;
vector<pair<string, string>>v(n);
for (auto& x : v)cin >> x.first >> x.second;
int nn = n;
int cnt = 0;
while (nn) {
nn /= 10;
cnt++;
}
unordered_map<string, ll>mp;
ll res1 = 0, res2 = 0, res3 = cnt, res = cnt;
for (int a = 0; a <= 10; a++) {
for (int b = 0; b <= 10; b++) {
string ss = "";
mp.clear();
int mx = 0;
for (auto& x : v) {
ss = x.first.substr(0, min(a, (int)x.first.size())) + x.second.substr(0, min(b, (int)x.second.size()));
mp[ss]++;
mx = max(mx, (int)mp[ss]);
}
int sum = a + b;
mx--;
while (mx) {
mx /= 10;
sum++;
}
if (sum <= res) {
res1 = a, res2 = b, res3 = sum - a - b;
res = sum;
}
}
}
cout << res1 << " " << res2 << " " << res3 << '\n';
return 0;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
int i = 1;
while (t--) {
//cout << "case " << i << ": ";
solve();
}
return 0;
}
/*
204
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3524kb
input:
1 11 sven eriksson erik svensson sven svensson erik eriksson bjorn eriksson bjorn svensson bjorn bjornsson erik bjornsson sven bjornsson thor odinsson odin thorsson
output:
1 1 0
result:
ok correct! (1 test case)
Test #2:
score: -100
Wrong Answer
time: 175ms
memory: 5168kb
input:
6 1 g u 14643 gj ek hc bi hi ke ab ij hk cj ha bi ag fe eb ej hd ei bf gj ke dd ib jd id jb gd ei cj bi bi hg ic dh ke gk af eg fg dd fe fa be ge hf kj ih ci gg jf ed dd eh gi cc kd ka fd af gb ka fe ja ed bc hi eg cf gg ff kf gf ii ch hh ec ei ec cd gc bh hb dd id ce bk ib ic bf kk gh cd hb he if g...
output:
0 0 0 2 2 1 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nie moga byc puste! (test case 1)