QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#105298 | #5499. Aliases | pdstiago# | WA | 120ms | 5172kb | C++14 | 1.5kb | 2023-05-13 21:20:45 | 2023-05-13 21:20:48 |
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=-1;
for(auto it=mapa.begin(); it!=mapa.end(); it++){
pair<string, int> agr = *it;
if(agr.second==1) continue;
maior=max(maior, agr.second);
}
int best=0;
if(maior!=-1){
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3372kb
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: 120ms
memory: 5172kb
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)