QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#560977#9156. 百万富翁oyzr100 ✓2485ms101628kbC++231.7kb2024-09-12 19:16:192024-09-12 19:16:19

Judging History

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

  • [2024-09-12 19:16:19]
  • 评测
  • 测评结果:100
  • 用时:2485ms
  • 内存:101628kb
  • [2024-09-12 19:16:19]
  • 提交

answer

#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
const int MAXN = 1e6 + 5;
// std::vector<int> ask(std::vector<int> a, std::vector<int> b);
int sol[8] = {500000, 250000, 125000, 62500, 20833, 3472, 183, 1};
int cnt[MAXN];
vector <int> a, b, res;
vector <int> v;
void Ask(int l, int r){
    for (int i = l; i <= r; i++){
        for (int j = i + 1; j <= r; j++){
            a.push_back(v[i]);
            b.push_back(v[j]);
        }
    }
}
void Solve(){
    res.clear();
    res = ask(a, b);
    a.clear(), b.clear();
    for (int i = 0; i < MAXN; i++)
        cnt[i] = 0;
    for (auto x: res)
        cnt[x]++;
}
int Ans(int l, int r){
    int len = r - l + 1;
    for (int i = l; i <= r; i++)
        if (cnt[v[i]] == len - 1)
            return v[i];
}
vector <pair <int, int> > now;
int richest(int N, int T, int S){
    v.clear();
    for (int i = 0; i < N; i++)
        v.push_back(i);
    if (N == 1000){
        Ask(0, 999);
        Solve();
        return Ans(0, 999);
    }else{
        int n = N;
        for (int i = 0; i < 8; i++){
            int num = sol[i];
            int cnt1 = num - n % num, len1 = n / num, cnt2 = n % num, len2 = n / num + 1;
            now.clear();
            for (int i = 1; i <= cnt1; i++)
                now.push_back({(i - 1) * len1, i * len1 - 1});
            for (int i = 1; i <= cnt2; i++)
                now.push_back({cnt1 * len1 + (i - 1) * len2, cnt1 * len1 + i * len2 - 1});
            for (auto x: now)
                Ask(x.first, x.second);
            Solve();
            v.clear();
            for (auto x: now)
                v.push_back(Ans(x.first, x.second));
            n = num;
        }
        return v[0];
    }
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 620ms
memory: 28224kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2485ms
memory: 101600kb

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: 629ms
memory: 28260kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2372ms
memory: 101628kb

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