QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#509014#9156. 百万富翁Qwerty1232#15 757ms23104kbC++231.6kb2024-08-08 02:22:092024-08-08 02:22:10

Judging History

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

  • [2024-08-08 02:22:10]
  • 评测
  • 测评结果:15
  • 用时:757ms
  • 内存:23104kb
  • [2024-08-08 02:22:09]
  • 提交

answer

#include <bits/stdc++.h>

#include "richest.h"

const std::string precalc_str_data = R"(
15
1 2  1 -1 -1
1 3  3 -1 -1
1 4  6 -1 -1
1 6  15 -1 -1
1 18  153 -1 -1
1 19  171 -1 -1
1 183  16653 -1 -1
2 4  3 2 1
2 18  33 6 1
2 19  36 6 1
2 3472  47856 183 1
3 8  7 2 1
4 16  15 2 1
4 62500  162444 3472 2
8 1000000  1099944 62500 4
)";

std::vector<int> select_multi(int t, std::vector<std::vector<int>> vec) {
    if (t == 1) {
        std::vector<int> a, b;
        for (int i = 0; i < vec.size(); i++) {
            auto& vc = vec[i];
            for (int i = 0; i < vc.size(); i++) {
                for (int j = i + 1; j < vc.size(); j++) {
                    a.push_back(vc[i]);
                    b.push_back(vc[j]);
                }
            }
        }
        std::vector<int> c = ask(a, b);
        std::sort(c.begin(), c.end());
        auto count = [&](int val) {
            auto [it1, it2] = std::equal_range(c.begin(), c.end(), val);
            return it2 - it1;
        };
        std::vector<int> ans(vec.size());
        for (int i = 0; i < vec.size(); i++) {
            ans[i] = vec[i].front();
            for (int j : vec[i]) {
                if (count(j) > count(ans[i])) {
                    ans[i] = j;
                }
            }
        }
        return ans;
    }
    assert(false);
}

int richest(int n, int t, int s) {
    t = std::min(t, 8);
    std::vector<int> all(n);
    std::iota(all.begin(), all.end(), 0);
    auto ans = select_multi(t, {all});
    assert(ans.size() == 1);
    return ans.front();
}

// 100 1 100000 5

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 757ms
memory: 21100kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Runtime Error

input:

1000000 20 2000000 29091473

output:

Unauthorized output

result:



Final Tests

Test #1:

score: 15
Accepted
time: 749ms
memory: 23104kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Runtime Error

input:

1000000 20 2000000 29091471

output:

Unauthorized output

result: