QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#145417#5499. AliasesTJ_AndevikingAC ✓6740ms25964kbC++201.5kb2023-08-22 11:53:132023-08-22 11:53:14

Judging History

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

  • [2023-08-22 11:53:14]
  • 评测
  • 测评结果:AC
  • 用时:6740ms
  • 内存:25964kb
  • [2023-08-22 11:53:13]
  • 提交

answer

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128_t int128;
typedef pair<int, int> pii;
#define iofast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) (x&(-x))
#define inv(x) qpow(x,mod-2)
#define debug(x) cout << (#x) << " = " << x << endl
#define range(x) (x).begin(), (x).end()

const int iINF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;

/*---------------------------------------*/

void solve()
{
    int n;
    cin >> n;
    vector<pair<string, string>>v(n);
    for (auto& [x, y] : v)
        cin >> x >> y;

    int mi = iINF;
    int a, b, c;
    for (int i = 0;i <= 6;++i)
        for (int j = 0;j + i <= 6;++j) {
            map<string, int>mp;
            for (const auto& [x, y] : v) {
                mp[x.substr(0, min(int(x.size()), i)) + y.substr(0, min(int(y.size()), j))]++;
            }

            int k = 1;
            for (const auto& [key, val] : mp)
                k = max(k, val);

            k--;
            if (k)
                k = to_string(k).size();
            if (i + j + k < mi)
                a = i, b = j, c = k, mi = i + j + k;
        }
    if (mi == 0)
        c = 1;
    cout << a << ' ' << b << ' ' << c << '\n';
}

/*---------------------------------------*/

int main()
{
    iofast;
    int t = 1;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 66ms
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 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: 345ms
memory: 6484kb

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: 6740ms
memory: 19488kb

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: 3829ms
memory: 25964kb

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)