QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105303 | #5499. Aliases | pdstiago# | WA | 2ms | 3388kb | C++14 | 1.5kb | 2023-05-13 21:32:41 | 2023-05-13 21:32:42 |
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);
n--;
int m = (int)num.size();
int resp=m;
int ar = 0, br = 0, cr = 0;
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: 0
Wrong Answer
time: 2ms
memory: 3388kb
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 1
result:
wrong answer Loginy nieunikalne! (test case 1)