QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105291 | #5499. Aliases | Time7# | AC ✓ | 14150ms | 26096kb | C++17 | 1.4kb | 2023-05-13 21:01:15 | 2023-05-13 21:01:17 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using lint = int64_t;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t; cin>>t;
while(t--){
int n; cin>>n;
vector<pair<string, string>> v(n);
for(auto &[first, last] : v) cin>>first>>last;
auto get_ans =[&](int a, int b) -> tuple<int, int, int, int> {
int maxi = 0;
map<string, int> cnt;
for(const auto &[first, last] : v){
string cur = "";
cur += first.substr(0, a);
cur += last.substr(0, b);
cnt[cur]++;
maxi = max(maxi, cnt[cur]);
//cout<<"\t"<<cur<<"\n";
}
int c = 0;
maxi--;
//cout<<maxi<<"\n";
while(maxi > 0){
c++;
maxi /= 10;
}
// cout<<a<<" "<<b<<" "<<c<<"\n";
if(a == 0 && b == 0 && c == 0)
c = 1;
return {a + b + c, a, b, c};
};
tuple<int, int, int, int> ans = {3*n, n, n, n};
for(int tot = 0; tot<=7; tot++)
for(int a=0; a <= tot; a++){
int b = tot - a;
ans = min(ans, get_ans(a, b));
}
auto [val, a, b, c] = ans;
cout<<a<<" "<<b<<" "<<c<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3400kb
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:
0 0 2
result:
ok correct! (1 test case)
Test #2:
score: 0
Accepted
time: 157ms
memory: 5176kb
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 1 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
ok correct! (6 test cases)
Test #3:
score: 0
Accepted
time: 793ms
memory: 6212kb
input:
6 5000 dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...
output:
0 0 4 0 1 3 1 1 2 2 0 2 1 2 1 3 0 1
result:
ok correct! (6 test cases)
Test #4:
score: 0
Accepted
time: 14150ms
memory: 19384kb
input:
6 113503 hxihfx mrqehftb oqmcc bwrbqomg dokyjc kuaiu hhfubp aleme xcnbe shxaqrf kzmqym geclklta jnxjq nppjx xeloxixa owsxnnj pzlvbyuk leioq xipez hoxgsml esujubw cwwzpei fekvoee vbxlts xjhcrkx qicmbmen rskvnrcx mpzpvvye lkkmkstn wlptoh wqgvr qbryq cqxydbr fzdxdrv wzofngxt keqwwhdl fkomzb sckpev geqe...
output:
4 0 1 2 2 1 1 3 1 3 0 2 1 2 2 1 1 3
result:
ok correct! (6 test cases)
Test #5:
score: 0
Accepted
time: 10259ms
memory: 26096kb
input:
6 1331 hidkxivneczxfctnobbqpxsgneaivgbodiejoqgbdthwsdsfzkxcdtzumcfdoawihskkwkehjdezgazzphrnkgncimntusqjqwimwbsztbzceqnwmnzzezwzazakknfwvdsyglpplwgnhwcgpriuwdmbvvlxaoruuuugamntnuqlvslsgvehhegjqpkcskonosndngfkokjcrqewtzzmypimrsoqqffwwzgzwhgfrrxmtptzfnretnoqjprpgqdhxcrccphsdmouuuidojxcyiknpfrrygjgwgwkb...
output:
1 2 0 3 1 0 4 1 0 2 3 0 0 5 0 0 0 6
result:
ok correct! (6 test cases)