QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129270 | #5499. Aliases | Forever_Young# | WA | 694ms | 9660kb | C++14 | 1015b | 2023-07-22 13:22:32 | 2023-07-22 13:22:33 |
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 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);
len=strlen(ts+1);
for(int j=1;j<=min(10,len+1);j++)s1[i][j]=ts[j];
scanf("%s",ts+1);
len=strlen(ts+1);
for(int j=1;j<=min(10,len+1);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==0)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<=a;j++)s+=s1[i][j];
for(int j=1;j<=b;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*36;
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: 7796kb
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 1 1
result:
ok correct! (1 test case)
Test #2:
score: -100
Wrong Answer
time: 694ms
memory: 9660kb
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 1 0 0 1 3 0 1 1 0 1 2 0 1 2 0 1 2
result:
wrong answer Loginy nieunikalne! (test case 2)