QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#537464#9156. 百万富翁shiomusubi496#91.00003 2765ms86644kbC++172.5kb2024-08-30 13:58:362024-08-30 13:58:36

Judging History

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

  • [2024-08-30 13:58:36]
  • 评测
  • 测评结果:91.00003
  • 用时:2765ms
  • 内存:86644kb
  • [2024-08-30 13:58:36]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)

#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)

using namespace std;

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

template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }

constexpr ll inf = 1001001001001001001;

int richest(int N, int T, int S) {
    if (T == 1) {
        vector<int> a, b;
        rep (i, N) rep (j, i) a.push_back(i), b.push_back(j);
        auto c = ask(a, b);
        vector<bool> used(N);
        rep (i, a.size()) used[a[i] ^ b[i] ^ c[i]] = true;
        rep (i, N) {
            if (!used[i]) return i;
        }
        return -1;
    }
    vector<int> A(N); iota(all(A), 0);
    auto calc = [&](int k) {
        int x = A.size() / k;
        int y = (k - A.size() % k) % k;
        if (y) {
            ++x;
            x -= y;
        }
        vector<int> X, Y;
        rep (i, x) {
            rep (a, k) rep (b, a) {
                X.push_back(A[i * k + a]);
                Y.push_back(A[i * k + b]);
            }
        }
        rep (i, y) {
            rep (a, k - 1) rep (b, a) {
                X.push_back(A[x * k + i * (k - 1) + a]);
                Y.push_back(A[x * k + i * (k - 1) + b]);
            }
        }
        vector<int> Z = ask(X, Y);
        vector<int> B;
        int t1 = k * (k - 1) / 2;
        int t2 = (k - 1) * (k - 2) / 2;
        {
            rep (i, x) {
                map<int, int> mp;
                rep (j, k) mp[A[i * k + j]] += k - 1;
                rep (j, t1) --mp[Z[i * t1 + j]];
                for (auto [a, b] : mp) {
                    if (b == 0) B.push_back(a);
                }
            }
        }
        {
            rep (i, y) {
                map<int, int> mp;
                rep (j, k - 1) mp[A[x * k + i * (k - 1) + j]] += k - 2;
                rep (j, t2) --mp[Z[x * t1 + i * t2 + j]];
                for (auto [a, b] : mp) {
                    if (b == 0) B.push_back(a);
                }
            }
        }
        A = B;
    };
    rep (_, 4) calc(2);
    calc(3);
    calc(6);
    calc(19);
    calc(A.size());
    return A[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 613ms
memory: 23036kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 76
Acceptable Answer
time: 2720ms
memory: 79744kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947


Final Tests

Test #1:

score: 15
Accepted
time: 616ms
memory: 22980kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 76
Acceptable Answer
time: 2765ms
memory: 86644kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947
708834003727782761
0.894118
11625001216319896173

result:

points 0.894118 Partially correct Case 2, 76 / 85, maxt = 8, maxs = 1099947