QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#508271#5499. AliasesSorahISAAC ✓3840ms38440kbC++205.8kb2024-08-07 12:03:442024-08-07 12:03:45

Judging History

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

  • [2024-08-07 12:03:45]
  • 评测
  • 测评结果:AC
  • 用时:3840ms
  • 内存:38440kb
  • [2024-08-07 12:03:44]
  • 提交

answer

#ifndef NYCU_MyGO
#define NYCU_MyGO
#include NYCU_MyGO __FILE__ NYCU_MyGO

void solve() {
    int N; cin >> N;
    
    vector<pair<string, string>> name(N);
    for (auto &[fir, lst] : name) cin >> fir >> lst;
    
    array<int, 3> ans{0, 0, 6};
    int min_ans = 6;
    for (int a = 0; a < min_ans; ++a) {
        for (int b = 0; a+b < min_ans; ++b) {
            int mx = 0;
            map<string, int> mp;
            for (const auto &[fir, lst] : name) {
                chmax(mx, ++mp[(SZ(fir) < a ? fir : fir.substr(0, a)) + (SZ(lst) < b ? lst : lst.substr(0, b))]);
            }
            int c = (mx == 1 ? 0 : SZ(to_string(mx-1)));
            if (chmin(min_ans, a + b + c)) ans = {a, b, c};
        }
    }
    if (min_ans == 0) cout << "0 0 1" << "\n";
    else cout << ans[0] << " " << ans[1] << " " << ans[2] << "\n";
}

int32_t main() {
    fastIO();
    
    int t = 1; cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
#define int i64
using f80 = long double;
#define dobule f80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

#ifdef local
#define fastIO() void()
#define debug(...) \
    fprintf(stderr, "\u001b[33m"), \
    fprintf(stderr, "At [%s], line %d: (%s) = ", __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), \
    fprintf(stderr, "\u001b[0m")
template <typename T> void _do(T &&_t) { cerr << _t << "\n"; }
template <typename T, typename ...U> void _do(T &&_t, U &&..._u) { cerr << _t << ", ", _do(_u...); }
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#endif

template <typename T, typename U> bool chmin(T &lhs, U rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; }
template <typename T, typename U> bool chmax(T &lhs, U rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; }

#endif

/**
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
 *                            iiiiii         iiiiiiiiii       iiiiiiiiiiiiii                                       
 *                       iiiiiiiiiiiii   iiiiiii    iiii    iiiiiiiiiiiiiii                          ii   iiii     
 *                    iiiiiiii     iiiiiiiii         iiii       iiii iii              iii          iiiiiiiiii      
 *                 iiiiiii          iiiiii           iiii    iiii   ii           iiiiiiiiii      iiii iiii         
 *               iiiiii            iiiii             iiii iiii        iii      iiii    iiiiiiiiiiiiiiiii  ii       
 *             iiiiii            iiiiiii            iiiiiii       iiiiiiii   iii    iiiiiiiiiiiiii iii  iiii       
 *           iiiiii             iiiiiii            iiiii   ii   iiii       iiiiiiiiiii iiii  iii iiii iiii      iii
 *          iiiii              iiiiiiii       ii        iiiii iiii    iiiiiiiii        iii iii  iii  iii  ii  iiii 
 *        iiiiii              iiiiiiii      iiiii     iiiii iiiiiiiiiiiiiiii         iii  iii  ii  iii  iii iiii   
 *       iiiii                 iiiiii     iiii     iiiiii iiiiiii    iii iii       iiii  ii   i   ii  iii  iii     
 *     iiiiii                            iiii  iiiiiiiiiiiiiii       iii iiii   iiiii  iii  ii  iii  iii  ii       
 *    iiiii                              iiiiiiii iiiiiiiiii       iiii   iiiiiiiii            ii  iii  ii         
 *   iiiii                                     iiiiii  iiii      iiiii              iii      ii   ii  i            
 * iiiiii                                  iiiiiiii   iiiii    iiiii                        ii  ii   ii            
 * iiiii                                iiii  iiii    iiiiiiiiiiii                             ii                  
 *  iii                              iiii   iiii       iiiiiiii                                                    
 *                                iiiii   iiii                                                                     
 *                              iiii     iiii                                                                      
 *                            iiii    iiiii                                                                        
 *                          iii     iiiii                                                                          
 *                        iii     iiiii                                                                            
 *                       iii   iiiiii                                                                              
 *                       iiiiiiiii                                                                                 
 *                       iiiiii                                                                                    
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
**/

詳細信息

Test #1:

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

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: 23ms
memory: 5248kb

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: 104ms
memory: 6332kb

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: 3840ms
memory: 19476kb

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: 2205ms
memory: 38440kb

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)