QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526468#9156. 百万富翁bashkort#81.999975 1930ms97512kbC++202.4kb2024-08-21 16:34:562024-08-21 16:34:57

Judging History

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

  • [2024-08-21 16:34:57]
  • 评测
  • 测评结果:81.999975
  • 用时:1930ms
  • 内存:97512kb
  • [2024-08-21 16:34:56]
  • 提交

answer

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

using namespace std;
using ll = long long;

int richest(int N, int T, int S) {
    vector<int> types{0, 0, 0, 0, 3, 6, 19, -1};
    if (T == 1) {
        types = {-1};
    }
    vector<int> a(N);
    iota(a.begin(), a.end(), 0);
    for (int x : types) {
        int n = a.size();
        if (x == 0) {
            vector<int> u, v;
            for (int i = 0; i < n; ++i) {
                (i % 2 ? v : u).push_back(a[i]);
            }
            int add = -1;
            if (u.size() > v.size()) {
                add = u.back();
                u.pop_back();
            }
            vector<int> res = ask(u, v);
            if (add != -1) {
                res.push_back(add);
            }
            a = res;
        } else if (x == -1) {
            vector<int> u, v;
            for (int i = 0; i < n; ++i) {
                for (int j = i + 1; j < n; ++j) {
                    u.push_back(a[i]);
                    v.push_back(a[j]);
                }
            }
            vector<int> res = ask(u, v);
            vector<int> cnt(N + 1);
            for (int &t : res) {
                cnt[t] += 1;
            }
            for (int t : a) {
                if (cnt[t] == n - 1) {
                    return t;
                }
            }
            assert(false);
            return -1;
        } else {
            int g = x;
            vector<int> u, v;
            for (int i = 0; i < n; ++i) {
                int nx = min(n, i / g * g + g);
                for (int j = i + 1; j < nx; ++j) {
                    u.push_back(a[i]);
                    v.push_back(a[j]);
                }
            }
            vector<int> res = ask(u, v);
            vector<int> cnt(N + 1), pos(N + 1, -1);
            for (int &t : res) {
                cnt[t] += 1;
            }
            for (int i = 0; i < n; ++i) {
                pos[a[i]] = i;
            }
            vector<int> l;
            int c = n / g;
            for (int t : a) {
                if (cnt[t] == g - 1) {
                    l.push_back(t);
                } else if (pos[t] / g >= c && cnt[t] == n % g - 1) {
                    l.push_back(t);
                }
            }
            a = l;
        }
        if (a.size() == 1) {
            break;
        }
    }
    return a[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 606ms
memory: 23416kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 67
Acceptable Answer
time: 1930ms
memory: 86716kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960
2586970244946203279
0.788235
12006835993993373281

result:

points 0.788235 Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960


Final Tests

Test #1:

score: 15
Accepted
time: 586ms
memory: 22076kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 67
Acceptable Answer
time: 1882ms
memory: 97512kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960
2586970244946203279
0.788235
12006835993993373281

result:

points 0.788235 Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960