QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#239677 | #5499. Aliases | KLPP# | WA | 95ms | 5192kb | C++20 | 1.3kb | 2023-11-04 22:23:48 | 2023-11-04 22:23:49 |
Judging History
answer
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int lld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
#define all(x) begin(x),end(x)
void solve(){
int n;
cin>>n;
vector<array<string,2>> a(n);
for(auto&[i,j]:a){
cin>>i>>j;
while(i.size()>6)i.pop_back();
while(j.size()>6)j.pop_back();
}
vector<long long> pow10(7);
pow10[0]=1;
for(int i=1;i<7;i++){
pow10[i]=10*pow10[i-1];
}
int sol=10;
int sola=0;
int solb=0;
int solc=0;
map<string,int> m;
for(int i=0;i<7;i++){
for(int j=0;j<7-i;j++){
m.clear();
int maxi=1;
for(auto[x1,x2]:a){
string s;
for(int k=0;k<min((int)x1.size(),i);k++){
s+=x1[k];
}
for(int k=0;k<min((int)x2.size(),j);k++){
s+=x2[k];
}
m[s]++;
maxi=max(maxi,m[s]);
}
int c=0;
while(pow10[c]<maxi)c++;
int thisSol=i+j+c;
if(sol>thisSol){
sol=thisSol;
sola=i;
solb=j;
solc=c;
}
}
}
cout<<sola<<' '<<solb<<' '<<solc<<'\n';
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int tt=1;
cin>>tt;
while(tt--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
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: -100
Wrong Answer
time: 95ms
memory: 5192kb
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 0 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nie moga byc puste! (test case 1)