QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105726 | #5499. Aliases | LeticiaFCS | WA | 71ms | 5588kb | C++20 | 1.3kb | 2023-05-15 09:09:07 | 2023-05-15 09:09:09 |
Judging History
answer
#include"bits/stdc++.h"
using lint = int64_t;
constexpr int MOD = int(1e9) + 7;
constexpr int INF = 0x63636363;
constexpr int NINF = 0xcfcfcfcf;
constexpr lint LINF = 0x6363636363636363;
using namespace std;
void solve(){
int n; cin>>n;
vector<array<string, 2>> v(n);
for(auto &name : v)
cin>>name[0]>>name[1];
tuple<int, int, int, int> ans = {3*n, n, n, n};
auto get_ans = [&](int a, int b) -> tuple<int, int, int, int> {
map<array<string, 2>, int> cnt;
int maxi_cnt = 0;
for(auto name : v){
array<string, 2> cur = {name[0].substr(0, a), name[1].substr(0, b)};
maxi_cnt = max(maxi_cnt, ++cnt[cur]);
}
int c = 0;
maxi_cnt--;
while(maxi_cnt > 0){
maxi_cnt /= 10;
c++;
}
if(a == 0 && b == 0 && c == 0)
c = 1;
return {a+b+c, a, b, c};
};
for(int tot = 0; tot <= 7; tot++)
for(int a = 0; 2*a <= tot; a++){
int b = tot - a;
ans = min(ans, get_ans(a, b));
}
auto [cost, a, b, c] = ans;
cout<<a<<' '<<b<<' '<<c<<"\n";
}
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int t; cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3396kb
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: -100
Wrong Answer
time: 71ms
memory: 5588kb
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 2 2 0 0 1 1 0 0 4 1 1 1 0 0 4
result:
wrong answer Loginy nieunikalne! (test case 2)