QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#178146#5499. Aliasesreal_sigma_team#WA 42ms5288kbC++201.5kb2023-09-13 18:34:302023-09-13 18:34:30

Judging History

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

  • [2023-09-13 18:34:30]
  • 评测
  • 测评结果:WA
  • 用时:42ms
  • 内存:5288kb
  • [2023-09-13 18:34:30]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using ll = long long;

const int N = 3e5 + 5;

int ask(int x) {
    cout << x << endl;
    cin >> x;
    return x;
}

int lg10(ll x) {
    int pw = 0;
    int cur = 1;
    while (cur < x) {
        pw++;
        cur *= 10;
    }
    return pw;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<string, string>> a(n);
    for (auto &[x, y]: a) cin >> x >> y;
    pair<pair<int, int>, int> ans = {{0, 0},
                                     {lg10(n)}};
    for (int i = 0; i <= lg10(n); ++i) {
        for (int j = 0; i + j <= lg10(n); ++j) {
            map<string, int> cnt;
            for (auto [x, y] : a) {
                string cur;
                cur += string(x.begin(), x.begin() + min((int)x.size(), i));
                cur += string(y.begin(), y.begin() + min((int)y.size(), j));
                cnt[cur]++;
            }
            int mx = 0;
            for (auto &[x, y] : cnt) {
                mx = max(mx, lg10(y));
            }
            if (i + j + mx < ans.first.first + ans.first.second + ans.second) {
                ans = {{i, j}, mx};
            }
        }
    }
    cout << ans.first.first << ' ' << ans.first.second << ' ' << ans.second << '\n';
}

int main() {
#ifndef LOCAL
#else
    freopen("input.txt", "r", stdin);
#endif
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 42ms
memory: 5288kb

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 0
0 0 5
0 1 1
1 0 2
1 1 1
2 0 1

result:

wrong answer Loginy nie moga byc puste! (test case 1)