QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#772487#9156. 百万富翁I_be_wanna100 ✓3424ms123636kbC++201.9kb2024-11-22 19:51:172024-11-22 19:51:17

Judging History

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

  • [2024-11-22 19:51:17]
  • 评测
  • 测评结果:100
  • 用时:3424ms
  • 内存:123636kb
  • [2024-11-22 19:51:17]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> getmx(int N, vector<vector<int>> vec) {
    vector<int> q1, q2;
    for (auto svec : vec) {
        for (int i = 0; i < (int)svec.size(); i++) {
            for (int j = i + 1; j < (int)svec.size(); j++) {
                q1.push_back(svec[i]);
                q2.push_back(svec[j]);
            }
        }
    }
    vector<int> res = ask(q1, q2);
    vector<int> cnt(N, 0);
    int cur = 0;
    for (auto svec : vec) {
        for (int i = 0; i < (int)svec.size(); i++) {
            for (int j = i + 1; j < (int)svec.size(); j++) {
                cnt[res[cur]]++;
                cur++;
            }
        }
    }
    vector<int> ret;
    for (auto svec : vec) {
        for (int i = 0; i < (int)svec.size(); i++) {
            if (cnt[svec[i]] == (int)svec.size() - 1) {
                ret.push_back(svec[i]);
            }
        }
    }
    return ret;
}
int richest(int N, int T, int S) {
    if (T == 1) {
        vector<int> vec;
        for (int i = 0; i < N; i++) {
            vec.push_back(i);
        }
        vector<vector<int>> tmp;
        tmp.push_back(vec);
        return getmx(N, tmp)[0];
    }
    vector<int> cur, nxt;
    for (int i = 0; i < N; i++) {
        cur.push_back(i);
    }
    const int t = 8;
    const int table[t] = {500000, 250000, 125000, 62500, 20833, 3472, 183, 1};
    for (int i = 0; i < t; i++) {
        int st = 0;
        vector<vector<int>> qs;
        for (int j = 0; j < table[i]; j++) {
            vector<int> q;
            int sz = (int)cur.size() / table[i] + (j < (int)cur.size() % table[i]);
            for (int ii = 0; ii < sz; ii++) {
                q.push_back(cur[st + ii]);
            }
            qs.push_back(q);
            st += sz;
        }
        cur = getmx(N, qs);
    }
    return cur[0];
}

詳細信息


Pretests

Pretest #1:

score: 15
Accepted
time: 602ms
memory: 23384kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 3424ms
memory: 120616kb

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: 602ms
memory: 23164kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 3406ms
memory: 123636kb

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