QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239766#5499. Aliaseselkernos#WA 1193ms5660kbC++233.0kb2023-11-04 23:09:582023-11-04 23:09:58

Judging History

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

  • [2023-11-04 23:09:58]
  • 评测
  • 测评结果:WA
  • 用时:1193ms
  • 内存:5660kb
  • [2023-11-04 23:09:58]
  • 提交

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;
        while (y--) {
            r *= x;
        }
        return r;
    };
    for (int a = 0; a <= 6; a++) {
        for (int b = 0; b <= 6; b++) {
            for (int c = 0; c <= 6; c++) {
                map<pair<string, string>, int> new_names;
                for (auto [x, y] : names) {
                    new_names[{x.substr(0, min(a, sz(x))), y.substr(0, min(b, sz(y)))}]++;
                }
                int ans = 0;
                for (auto [_, x] : new_names) {
                    ans = max(ans, x);
                }
                if (ans <= mypow(10, c) && a + b + c < minsum) {
                    minsum = a + b + c;
                    ra = a;
                    rb = b;
                    rc = 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: 3512kb

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: 1193ms
memory: 5660kb

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

result:

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