QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#696880#9156. 百万富翁makrav100 ✓2626ms98048kbC++203.2kb2024-11-01 04:54:072024-11-01 04:54:07

Judging History

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

  • [2024-11-01 04:54:07]
  • 评测
  • 测评结果:100
  • 用时:2626ms
  • 内存:98048kb
  • [2024-11-01 04:54:07]
  • 提交

answer

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

using namespace std;

#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

mt19937 rnd(time(NULL));

template<typename T>
void make_shuf(vector<T>& v) {
    for (int i = 1; i < sz(v); i++) swap(v[i], v[rnd() % (i + 1)]);
}

int richest(int N, int T, int S) {
    if (N <= 1000) {
        vector<int> a, b;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                a.pb(i); b.pb(j);
            }
        }
        auto rs = ask(a, b);
        vector<int> deg(N);
        for (int i = 0; i < sz(a); i++) {
            deg[rs[i]]++;
        }   
        for (int i = 0; i < N; i++) {
            if (deg[i] == N - 1) return i;
        }
        return -1;
    }

    auto make_op = [&](vector<int> guys, int parts, int secval) {
        parts = min(parts, sz(guys));
            vector<vector<int>> mns(parts);
            int cur = 0;
            for (int i = 0; i < sz(guys); i++) {
                mns[cur].pb(guys[i]);
                cur = (cur + 1 < parts ? cur + 1 : 0);
            }
            if (secval == 1) {
                for (int j = 0; j < sz(guys) % parts; j++) {
                    mns.pb({mns[j].back()});
                    mns[j].pop_back();
                }
            }
            else if (secval == 2) {
                int cnt_rows = (sz(guys) + parts - 1) / parts;
                int C = sz(guys) / cnt_rows;
                mns.assign(C + 1, {});
                int ind = 0;
                for (int g : guys) {
                    if (mns[ind].size() == cnt_rows) ind++;
                    mns[ind].pb(g);
                }
            }
            vector<int> A, B;
            vector<int> cntt(mns[0].size());
            for (int i = 0; i < mns[0].size(); i++) {
                for (int mn1 = 0; mn1 < sz(mns); mn1++) {
                    if (sz(mns[mn1]) <= i) break;
                    cntt[i]++;
                    for (int mn2 = mn1 + 1; mn2 < sz(mns); mn2++) {
                        if (sz(mns[mn1]) > i && sz(mns[mn2]) > i) {
                            A.pb(mns[mn1][i]); B.pb(mns[mn2][i]);
                        }
                    }
                }
            }
            auto rs = ask(A, B);
            vector<int> ret;
            int ind = 0;
            vector<int> deg(N);
            for (int i = 0; i < mns[0].size(); i++) {
                for (int j = ind; j < min(sz(rs), ind + (cntt[i] * (cntt[i] - 1) / 2)); j++) {
                    deg[rs[j]]++;
                }
                for (int mn1 = 0; mn1 < sz(mns); mn1++) {
                    if (sz(mns[mn1]) > i && deg[mns[mn1][i]] == cntt[i] - 1) {
                        ret.pb(mns[mn1][i]);
                        break;
                    }
                }
                ind += (cntt[i] * (cntt[i] - 1) / 2);
            }   
            return ret;
        
    }; 
    vector<int> parts = {2, 2, 2, 2, 3, 6, 19, 183};
    vector<int> val2 = {0, 0, 0, 0, 1, 1, 2, 0};
    vector<int> A(N); iota(all(A), 0);
    int curind = 0;
    for (int el : parts) {
        A = make_op(A, el, val2[curind++]);
    }
    return A[0];
}

详细


Pretests

Pretest #1:

score: 15
Accepted
time: 628ms
memory: 25380kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2626ms
memory: 98016kb

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: 623ms
memory: 25284kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2619ms
memory: 98048kb

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