QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#225208#5499. AliasesGawor270AC ✓16328ms35600kbC++171.7kb2023-10-24 05:51:032023-10-24 05:51:04

Judging History

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

  • [2023-10-24 05:51:04]
  • 评测
  • 测评结果:AC
  • 用时:16328ms
  • 内存:35600kb
  • [2023-10-24 05:51:03]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define debug(x) cout << "[" <<  #x << " " << x << "] ";

#define ar array
#define ll long long
#define ld long double
#define sz(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()

typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;


vector<string> firstname;
vector<string> lastname;

int ispos(int a, int b){
    map<string,int> count;
    int maxim = 0;
    for(int i=0; i<firstname.size(); i++){
        int l1 = firstname[i].length();
        int l2 = lastname[i].length();
        string res = firstname[i].substr(0,min(l1,a)) + lastname[i].substr(0,min(l2,b));
        count[res]++;
        maxim = max(maxim,count[res]);
    }
    int c = ceil(log10(maxim)); 
    return c;

}

void solve() {
    int n;
    cin >> n;
    firstname.resize(n), lastname.resize(n);
    int maxf =0, maxl = 0;
    for(int i=0; i<n; i++){
        cin >> firstname[i] >> lastname[i];
        maxf = max((int)firstname[i].length(), maxf);
        maxl = max((int)lastname[i].length(), maxl);
    }

    int a = 0,b = 0,c = 6;
    int minim = 6;
    for(int i=0; i<=6; i++){
        for(int j=0; j<=6; j++){
                int k = ispos(i,j);
                if((i || j || k) && i + j + k < minim){
                    minim = i + j + k;
                    a = i, b= j, c = k;
                }
        }
    }

    cout << a << " " << b << " " << c << "\n";
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3780kb

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: 229ms
memory: 5472kb

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 1 0
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: 1012ms
memory: 7880kb

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: 16328ms
memory: 24508kb

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: 12643ms
memory: 35600kb

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)