QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#221653#5499. Aliasesucup-team859#AC ✓3099ms28484kbC++171.9kb2023-10-21 14:07:142023-10-21 14:07:14

Judging History

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

  • [2023-10-21 14:07:14]
  • 评测
  • 测评结果:AC
  • 用时:3099ms
  • 内存:28484kb
  • [2023-10-21 14:07:14]
  • 提交

answer

#include <bits/stdc++.h>

#define lsb(x) (x & (-x))

using ull = unsigned long long;
using ll = long long;

using namespace std;



int main() {
#ifdef HOME
    ifstream cin("input.in");
    ofstream cout("output.out");
#endif
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t;
    cin >> t;

    for (int tt = 1; tt <= t; tt++) {
        int n;
        cin >> n;

        vector<string> A(n), B(n);
        for (int i = 0; i < n; i++) {
            cin >> A[i] >> B[i];
        }

        constexpr int MAXANS = 6;
        int answer = MAXANS;
        vector<int> sol = {0, 0, MAXANS};

        vector<string> temp(n);

        for (int a = 0; a <= MAXANS; a++) {
            for (int b = 0; a + b <= MAXANS; b++) {
                if (a + b > answer) continue;

                for (int i = 0; i < n; i++) {
                    temp[i] = A[i].substr(0, a) + B[i].substr(0, b);
                }

                sort(temp.begin(), temp.end());

                auto Get = [](int x) {
                    int pw = 1, e = 0;
                    while (pw < x) {
                        pw *= 10;
                        e++;
                    }
                    return e;
                };

                int c = 0;
                int i = 0;
                while (i < n) {
                    int j = i;
                    while (j < n && temp[i] == temp[j]) {
                        j++;
                    }
                    c = max(c, Get(j - i));
                    i = j;
                }

                if (answer > a + b + c) {
                    answer = a + b + c;
                    sol = {a, b, c};
                }
            }
        }
        
        if (answer == 0) {
            sol[2] = 1;
        }
        cout << sol[0] << " " << sol[1] << " " << sol[2] << "\n"; 
    }   

    return 0;
}

详细

Test #1:

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

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: 50ms
memory: 4532kb

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: 155ms
memory: 5976kb

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: 2894ms
memory: 14212kb

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: 3099ms
memory: 28484kb

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)