QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#426212 | #5499. Aliases | wsc2008 | WA | 266ms | 19984kb | C++14 | 1.5kb | 2024-05-30 22:47:31 | 2024-05-30 22:47:32 |
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;
while(x)len++,x/=10;
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,str2;
if(s[i].size()>=a)str1=s[i].substr(0,a);
else str1=s[i];
if(t[i].size()>=b)str2=t[i].substr(0,b);
else str2=t[i];
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: 4ms
memory: 16316kb
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: 51ms
memory: 17464kb
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: -100
Wrong Answer
time: 266ms
memory: 19984kb
input:
6 5000 dpbcebnavonpwlkermqftinonhckqynyxfwsybsalgmpqmedykqeunbolxhtcnrvbiqrjgziptkqgbsxrprapfzjxefiioecsacujyuhvsapywqohliffaqsbupnocesbgqutaanduiztwwqulwvrx dyearafwtdkifljtvcryeyfzgqghjwhuycusqkxngmanxxjhyqaethbfoqaigbbjuutwzzazsgcguaasrrrzsapcuhvzzjllatjqtxzrotdpcrrdogfwoonxjwisdwhqntlhqpflxvcido...
output:
0 0 4 0 1 3 1 1 2 2 0 2 1 2 1 0 0 5
result:
wrong answer Rozwiazanie nieoptymalne! (test case 6)