QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#87355 | #5499. Aliases | chiranko# | AC ✓ | 7007ms | 142992kb | C++20 | 1.1kb | 2023-03-12 18:18:01 | 2023-03-12 18:18:03 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
using namespace std;
inline int read(){
int x=0,f=1;char ch=' ';
while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0' && ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
return f==1?x:-x;
}
const int N=2e6+5;
int T,n;
string A[N],B[N];
map<string,int> mp;
int main(){
T=read();
while(T--){
n=read();
for(int i=1;i<=n;++i){
cin>>A[i]>>B[i];
}
int ans=6,aa=0,bb=0,cc=6;
for(int a=0;a<6;++a){
for(int b=0;a+b<6;++b){
mp.clear();
for(int i=1;i<=n;++i){
string s1=A[i].substr(0,min(a,(int)A[i].length()));
string s2=B[i].substr(0,min(b,(int)B[i].length()));
string s=s1+s2;
if(mp.find(s)==mp.end())mp[s]=1;
else mp[s]++;
}
int mx=1;
for(auto x:mp)mx=max(mx,x.second);
int c=0;
int now=1;
while(now<mx){
now*=10;
c++;
}
if(a+b+c<ans){
ans=a+b+c;
aa=a;
bb=b;
cc=c;
}
}
}
if(!aa && !bb && !cc)cc=1;
printf("%d %d %d\n",aa,bb,cc);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 20ms
memory: 128652kb
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: 0
Accepted
time: 107ms
memory: 129680kb
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 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
ok correct! (6 test cases)
Test #3:
score: 0
Accepted
time: 549ms
memory: 132932kb
input:
6 5000 dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...
output:
0 0 4 0 1 3 1 1 2 2 0 2 1 2 1 3 0 1
result:
ok correct! (6 test cases)
Test #4:
score: 0
Accepted
time: 7007ms
memory: 137372kb
input:
6 113503 hxihfx mrqehftb oqmcc bwrbqomg dokyjc kuaiu hhfubp aleme xcnbe shxaqrf kzmqym geclklta jnxjq nppjx xeloxixa owsxnnj pzlvbyuk leioq xipez hoxgsml esujubw cwwzpei fekvoee vbxlts xjhcrkx qicmbmen rskvnrcx mpzpvvye lkkmkstn wlptoh wqgvr qbryq cqxydbr fzdxdrv wzofngxt keqwwhdl fkomzb sckpev geqe...
output:
4 0 1 2 2 1 1 3 1 3 0 2 1 2 2 1 1 3
result:
ok correct! (6 test cases)
Test #5:
score: 0
Accepted
time: 4421ms
memory: 142992kb
input:
6 1331 hidkxivneczxfctnobbqpxsgneaivgbodiejoqgbdthwsdsfzkxcdtzumcfdoawihskkwkehjdezgazzphrnkgncimntusqjqwimwbsztbzceqnwmnzzezwzazakknfwvdsyglpplwgnhwcgpriuwdmbvvlxaoruuuugamntnuqlvslsgvehhegjqpkcskonosndngfkokjcrqewtzzmypimrsoqqffwwzgzwhgfrrxmtptzfnretnoqjprpgqdhxcrccphsdmouuuidojxcyiknpfrrygjgwgwkb...
output:
1 2 0 3 1 0 4 1 0 2 3 0 0 5 0 0 0 6
result:
ok correct! (6 test cases)