QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224947#5499. AliasessgrcnWA 44ms5336kbC++171.2kb2023-10-23 18:16:202023-10-23 18:16:21

Judging History

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

  • [2023-10-23 18:16:21]
  • 评测
  • 测评结果:WA
  • 用时:44ms
  • 内存:5336kb
  • [2023-10-23 18:16:20]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

int n;
vector<pair<string, string>> V;

bool calc(int a, int b, int c) {
    map<string, int> M;
    for(int i = 0 ; i < n ; ++i) {
        string key = V[i].first.substr(0,a)+V[i].second.substr(0,b);
        M[key]++;
    }
    int maxl = pow(10, c);
    for(const auto c : M) {
        if(c.second > maxl) return false;
    }
    return true;
}

void solve() {
    int p = 1;
    while(pow(10, p) < n) p++;
    int mina, minb, minc;
    mina = minb = minc = p;
    for(int i = 0 ; i <= p ; ++i) {
        for(int j = 0 ; j <= p ; ++j) {
            for(int k = 0 ; k <= p ; ++k) {
                if(i+j+k>=mina+minb+minc) continue;
                if(calc(i, j, k)) {
                    mina = i; minb = j; minc = k;
                }
            }
        }
    }
    cout << mina << ' ' << minb << ' ' << minc;
}

int main() {
    ios_base::sync_with_stdio(false); cout.tie(nullptr); cin.tie( nullptr);

    int t;
    cin >> t;
    while(t--) {
        cin >> n;
        V = vector<pair<string, string>>(n);
        for(int i = 0 ; i < n ; ++i) cin >> V[i].first >> V[i].second;
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3676kb

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: 44ms
memory: 5336kb

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 00 0 50 1 11 0 21 1 12 0 1

result:

wrong output format Expected integer, but "00" found (test case 1)