QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#239688 | #5499. Aliases | KLPP# | WA | 531ms | 6472kb | C++20 | 1.3kb | 2023-11-04 22:28:57 | 2023-11-04 22:28:57 |
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();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
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: 96ms
memory: 5252kb
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: 531ms
memory: 6472kb
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)