QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239780#5499. Aliaseselkernos#WA 6148ms25980kbC++233.1kb2023-11-04 23:18:312023-11-04 23:18:31

Judging History

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

  • [2023-11-04 23:18:31]
  • 评测
  • 测评结果:WA
  • 用时:6148ms
  • 内存:25980kb
  • [2023-11-04 23:18:31]
  • 提交

answer

// clang-format off
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
template<class Fun>
class y_combinator_result {
    Fun fun_;
public:
    template<class T> explicit y_combinator_result(T &&fun): fun_(forward<T>(fun)) {}
    template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(ref(*this), forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<decay_t<Fun>>(forward<Fun>(fun)); }
// using namespace __gnu_pbds;
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef XOX
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; }
sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
struct { template <class T> operator T() { T x; cin >> x; return x; } } in;
#define endl '\n'
#define pb emplace_back
#define vt vector
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using i64 = long long;
// clang-format on

void solve() {
    int n;
    cin >> n;
    vector<pair<string, string>> names(n);
    for (auto &[a, b] : names) {
        cin >> a >> b;
    }
    int minsum = INT_MAX;
    int ra, rb, rc;
    auto mypow = [&](int x, int y) {
        int r = 1;
        if (y == 0) {
            return 0;
        }
        while (y--) {
            r *= x;
        }
        return r;
    };
    for (int a = 0; a <= 6; a++) {
        for (int b = 0; a + b <= 6; b++) {
            map<string, int> new_names;
            for (auto [x, y] : names) {
                string uname = x.substr(0, min(a, sz(x))) + y.substr(0, min(b, sz(y)));
                new_names[uname]++;
            }
            int ans = 0;
            for (auto [_, x] : new_names) {
                ans = max(ans, x);
            }
            int need_c = 1;
            for(int c = 0; c <= 6; c++) {
                if(ans <= mypow(10, c)) {
                    need_c = c;
                    break;
                }
            }
            if (a + b + need_c < minsum) {
                minsum = a + b + need_c;
                ra = a;
                rb = b;
                rc = need_c;
            }
        }
    }
    cout << ra << " " << rb << " " << rc << endl;
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    // int t = 1;
    int t = in;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 70ms
memory: 5284kb

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: 405ms
memory: 6440kb

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: 6148ms
memory: 19580kb

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: -100
Wrong Answer
time: 4075ms
memory: 25980kb

input:

6
1331
hidkxivneczxfctnobbqpxsgneaivgbodiejoqgbdthwsdsfzkxcdtzumcfdoawihskkwkehjdezgazzphrnkgncimntusqjqwimwbsztbzceqnwmnzzezwzazakknfwvdsyglpplwgnhwcgpriuwdmbvvlxaoruuuugamntnuqlvslsgvehhegjqpkcskonosndngfkokjcrqewtzzmypimrsoqqffwwzgzwhgfrrxmtptzfnretnoqjprpgqdhxcrccphsdmouuuidojxcyiknpfrrygjgwgwkb...

output:

0 0 4
0 0 5
0 0 6
0 0 6
0 0 6
0 0 6

result:

wrong answer Rozwiazanie nieoptymalne! (test case 1)