QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#426213 | #5499. Aliases | wsc2008 | AC ✓ | 4562ms | 30260kb | C++14 | 1.4kb | 2024-05-30 22:50:01 | 2024-05-30 22:50:01 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe;
ll read(){
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
void write(ll x){
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
}
const ll N=2e5+9;
ll T,n;
string s[N],t[N];
map<string,ll>mp;
ll runi(ll x){
ll len=0,p=1;
while(p<x)p*=10,len++;
return len;
}
void solve(){
cin>>n;
rep(i,1,n)cin>>s[i]>>t[i];
ll A=0,B=0,C=6;
rep(a,0,6){
rep(b,0,6){
if(a+b>=6)break;
mp.clear();
rep(i,1,n){
string str1=s[i].substr(0,a),str2=t[i].substr(0,b);
str1+=str2;
mp[str1]++;
}
ll c=0;
for(pair<string,ll>p:mp)c=max(c,runi(p.second));
if(!(a+b+c))c++;
if(a+b+c<A+B+C)A=a,B=b,C=c;
}
}
cout<<A<<" "<<B<<" "<<C<<"\n";
}
bool Med;
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
cin>>T;
while(T--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 16344kb
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: 45ms
memory: 17716kb
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: 271ms
memory: 20232kb
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: 4562ms
memory: 25340kb
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: 2624ms
memory: 30260kb
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)