QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138224 | #5499. Aliases | Flamire | WA | 1722ms | 75148kb | C++14 | 995b | 2023-08-11 10:04:27 | 2023-08-11 10:04:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
int t,n,lg[1000011];string s[200011][2];const ull B=801,VB=10393913;
vector<ull> hsh[200011][2];
unordered_map<ull,int> mp;
int main()
{
lg[1]=1;for(int i=2;i<=1000000;++i)lg[i]=ceil(log10(i)-1e-7);
scanf("%d",&t);while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;++i)cin>>s[i][0]>>s[i][1],hsh[i][0].resize(s[i][0].length()+1),hsh[i][1].resize(s[i][1].length()+1);
for(int i=1;i<=n;++i)
{
hsh[i][0][0]=hsh[i][1][0]=0;
for(int j=0;j<s[i][0].length();++j)hsh[i][0][j+1]=hsh[i][0][j]*B+s[i][0][j];
for(int j=0;j<s[i][1].length();++j)hsh[i][1][j+1]=hsh[i][1][j]*B+s[i][1][j];
}
int A=6,B=6,C=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)++mp[hsh[i][0][a]*VB+hsh[i][1][b]];
int c=0;
for(auto x:mp)c=max(c,lg[x.second]);
if(a+b+c<A+B+C)A=a,B=b,C=c;
}
}
printf("%d %d %d\n",A,B,C);
}return 0;
}
详细
Test #1:
score: 100
Accepted
time: 13ms
memory: 29588kb
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: 20ms
memory: 31196kb
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: 174ms
memory: 53200kb
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: 1722ms
memory: 61764kb
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: -100
Wrong Answer
time: 1448ms
memory: 75148kb
input:
6 1331 hidkxivneczxfctnobbqpxsgneaivgbodiejoqgbdthwsdsfzkxcdtzumcfdoawihskkwkehjdezgazzphrnkgncimntusqjqwimwbsztbzceqnwmnzzezwzazakknfwvdsyglpplwgnhwcgpriuwdmbvvlxaoruuuugamntnuqlvslsgvehhegjqpkcskonosndngfkokjcrqewtzzmypimrsoqqffwwzgzwhgfrrxmtptzfnretnoqjprpgqdhxcrccphsdmouuuidojxcyiknpfrrygjgwgwkb...
output:
0 0 4 0 0 5 0 0 6 3 0 2 0 0 6 0 0 6
result:
wrong answer Rozwiazanie nieoptymalne! (test case 1)