QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239756#5499. AliasesKLPP#AC ✓8757ms38460kbC++201.4kb2023-11-04 23:01:022023-11-04 23:01:02

Judging History

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

  • [2023-11-04 23:01:02]
  • 评测
  • 测评结果:AC
  • 用时:8757ms
  • 内存:38460kb
  • [2023-11-04 23:01:02]
  • 提交

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

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: 95ms
memory: 5232kb

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: 526ms
memory: 6248kb

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: 8757ms
memory: 19376kb

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: 6143ms
memory: 38460kb

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)