QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688250#9156. 百万富翁nor100 ✓3453ms140584kbC++232.0kb2024-10-30 01:32:142024-10-30 01:32:15

Judging History

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

  • [2024-10-30 01:32:15]
  • 评测
  • 测评结果:100
  • 用时:3453ms
  • 内存:140584kb
  • [2024-10-30 01:32:14]
  • 提交

answer

// B

#include "richest.h"

#include <bits/stdc++.h>
using namespace std;

const vector<int> subtasks[2] = {
    {1000, 1}, {1000000, 500000, 250000, 125000, 62496, 20832, 3472, 183, 1}};

const int MAX_N = 1'000'005;
int _del_date[MAX_N];
int _cur_date = 1;

vector<int> query(vector<vector<int>> groups) {
    _cur_date++;
    vector<int> side_a, side_b;
    for (vector<int> &group : groups) {
        for (int a : group) {
            for (int b : group) {
                if (a == b) {
                    break;
                }
                side_a.push_back(a);
                side_b.push_back(b);
            }
        }
    }
    vector<int> response = ask(side_a, side_b);

    for (int i = 0; i < side_a.size(); i++) {
        if (response[i] == side_a[i]) {
            _del_date[side_b[i]] = _cur_date;
        } else {
            _del_date[side_a[i]] = _cur_date;
        }
    }

    vector<int> res;
    for (vector<int> &group : groups) {
        for (int a : group) {
            if (_del_date[a] != _cur_date) {
                res.push_back(a);
            }
        }
    }
    return res;
}

#define ask
int richest(int N, int T, int S) {
    vector<int> sizes = subtasks[T != 1];
    _cur_date++;
    vector<int> candidates(N);
    iota(candidates.begin(), candidates.end(), 0);
    for (int d = 1; d < sizes.size(); d++) {
        int before = sizes[d - 1], after = sizes[d];
        int div = before / after;
        int rem = before % after;

        assert(candidates.size() <= before);
        vector<vector<int>> groups;
        int idx = 0;
        for (int gi = 0; gi < after; gi++) {
            vector<int> group;
            for (int _i = gi >= rem; _i <= div; _i++) {
                if (idx == candidates.size()) break;
                group.push_back(candidates[idx++]);
            }
            groups.push_back(group);
        }
        candidates = query(groups);

        assert(candidates.size() <= after);
    }
    return candidates[0];
}
#undef ask

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 618ms
memory: 25156kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 3453ms
memory: 127376kb

input:

1000000 20 2000000 29091473

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944


Final Tests

Test #1:

score: 15
Accepted
time: 626ms
memory: 24988kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 3444ms
memory: 140584kb

input:

1000000 20 2000000 29091471

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944