QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#298070 | #5499. Aliases | ushg8877# | WA | 31ms | 16908kb | C++14 | 782b | 2024-01-05 17:04:13 | 2024-01-05 17:04:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=2e5+5;
int n;
string s[MAXN],t[MAXN];
int lg[MAXN];
void solve(){
cin>>n;
for(int i=1;i<=n;i++) cin>>s[i]>>t[i];
int a=100,b=100,c=100;
for(int i=0;i<=6;i++) for(int j=0;j<=6;j++){
map<string,int> mp;
for(int k=1;k<=n;k++){
string p="";
for(int q=0;q<i&&q<s[k].length();q++) p+=s[q];
for(int q=0;q<j&&q<t[k].length();q++) p+=t[q];
mp[p]++;
}
int mx=0;
for(auto k:mp) mx=max(mx,k.second);
mx=lg[mx-1];
if(a+b+c>i+j+mx) a=i,b=j,c=mx;
}
cout<<a<<' '<<b<<' '<<c<<endl;
}
int main(){
ios::sync_with_stdio(false);
for(int i=1;i<MAXN;i++) lg[i]=lg[i/10]+1;
int _;cin>>_;
while(_--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 16908kb
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: 31ms
memory: 16832kb
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 0 0 5 0 0 3 0 0 4 0 0 4 0 0 4
result:
wrong answer Loginy nie moga byc puste! (test case 1)