QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129281 | #5499. Aliases | Forever_Young# | AC ✓ | 8326ms | 26632kb | C++14 | 1.1kb | 2023-07-22 13:37:01 | 2023-07-22 13:37:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
char ts[1600000];
char s1[210000][20],s2[210000][20];
int len1[210000],len2[210000];
int n,ansa,ansb,ansc;
int main()
{
int T;
cin>>T;
while (T--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int len;
scanf("%s",ts+1);
len1[i]=strlen(ts+1);
for(int j=1;j<=min(10,len1[i]);j++)s1[i][j]=ts[j];
scanf("%s",ts+1);
len2[i]=strlen(ts+1);
for(int j=1;j<=min(10,len2[i]);j++)s2[i][j]=ts[j];
}
int ans=2147483647;
for(int a=0;a<=10;a++)
for(int b=0;b<=10;b++)
{
if (a+b>6)continue;
static map<string,int> dic; dic.clear();
int maxcnt=0;
for(int i=1;i<=n;i++)
{
string s="";
for(int j=1;j<=min(a,len1[i]);j++)s+=s1[i][j];
for(int j=1;j<=min(b,len2[i]);j++)s+=s2[i][j];
dic[s]++;
maxcnt=max(maxcnt,dic[s]);
}
int c=0; long long now=1;
while (now<maxcnt)c++,now=now*10;
if (a+b+c==0)c++;
if (ans>a+b+c)ans=a+b+c,ansa=a,ansb=b,ansc=c;
}
printf("%d %d %d\n",ansa,ansb,ansc);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 9844kb
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: 97ms
memory: 9052kb
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: 521ms
memory: 8840kb
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: 8326ms
memory: 21652kb
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: 5520ms
memory: 26632kb
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)