QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105299 | #5499. Aliases | pdstiago# | WA | 114ms | 5088kb | C++14 | 1.5kb | 2023-05-13 21:22:52 | 2023-05-13 21:22:54 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define mxn 1e5+5
#define fastio ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define endl '\n'
#define INF 0x3f3f3f3f
typedef long long ll;
int solve(){
int n;
cin >> n;
vector<pair<string, string> > v(n+1);
for(int i=1; i<=n; i++){
cin >> v[i].first >> v[i].second;
}
string num = to_string(n);
int m = (int)num.size();
int resp=m;
int ar, br, cr;
for(int a=0; a<=m; a++){
for(int b=0; b<=m; b++){
map<string, int> mapa;
for(int i=1; i<=n; i++){
string as = v[i].first.substr(0, min(a, (int)v[i].first.size()));
string bs = v[i].second.substr(0, min(b, (int)v[i].second.size()));
mapa[as+bs]++;
}
int maior=0;
for(auto it=mapa.begin(); it!=mapa.end(); it++){
pair<string, int> agr = *it;
maior=max(maior, agr.second);
}
int best=0;
maior--;
if(maior>0){
string agr = to_string(maior);
best = (int)agr.size();
}
if(a+b+best<=resp){
resp=a+b+best;
ar=a, br=b, cr=best;
}
}
}
cout << ar << " " << br << " " << cr << endl;
return 0;
}
int main(){
fastio;
int t = 1;
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: 3432kb
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: 114ms
memory: 5088kb
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)