QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198215#5499. Aliasesgrass8cow#AC ✓8255ms33404kbC++14807b2023-10-03 09:52:362023-10-03 09:52:36

Judging History

你现在查看的是最新测评结果

  • [2023-10-03 09:52:36]
  • 评测
  • 测评结果:AC
  • 用时:8255ms
  • 内存:33404kb
  • [2023-10-03 09:52:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,t1[200100],t2[200100];
string s1[201000],s2[201000];
int vis[1010000];
map<string,int>ti;
void sol(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s1[i]>>s2[i],
	t1[i]=s1[i].length(),t2[i]=s2[i].length();
	int ai=0,bi=0,ci=6;
	for(int a=0;a<=6;a++)for(int b=0;a+b<=6;b++){
		ti.clear();int c=0;
		for(int i=1;i<=n;i++){
			string ss="O";
			for(int j=0;j<min(t1[i],a);j++)ss.push_back(s1[i][j]);
			for(int j=0;j<min(t2[i],b);j++)ss.push_back(s2[i][j]);
			ti[ss]++;
			if(vis[ti[ss]])c=max(c,vis[ti[ss]]);
		}
		if(!a&&!b&&!c)c++;
		if(a+b+c<ai+bi+ci)
		ai=a,bi=b,ci=c;
	}
	printf("%d %d %d\n",ai,bi,ci);
}
int main(){
	for(int i=0,j=1;i<=6;i++,j*=10)vis[j+1]=i+1;
	ios::sync_with_stdio();
	int T;cin>>T;while(T--)sol();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 18192kb

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: 104ms
memory: 17776kb

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: 602ms
memory: 22432kb

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: 8255ms
memory: 26948kb

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: 5595ms
memory: 33404kb

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)