QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#239754#5499. AliasesKLPP#RE 0ms3400kbC++201.4kb2023-11-04 22:59:252023-11-04 22:59:26

Judging History

你现在查看的是最新测评结果

  • [2023-11-04 22:59:26]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3400kb
  • [2023-11-04 22:59:25]
  • 提交

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;
    if(n==1){
	cout<<"0 0 1\n";
	return;
    }
    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;
	    }
	}
    }
    assert(!(sola==0&&solb==0&&solc==0));
    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: 0ms
memory: 3400kb

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
Runtime Error

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:


result: