QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#510061#9156. 百万富翁Franuch#0 1ms8268kbC++171.7kb2024-08-08 20:54:112024-08-08 20:54:16

Judging History

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

  • [2024-08-08 20:54:16]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:8268kb
  • [2024-08-08 20:54:11]
  • 提交

answer

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

using namespace std;
typedef int ll;
//
//ll on2(ll n) {
//    vector<ll> a, b;
//    for (ll i = 1; i < n; i++) {
//        for (ll j = 0; j < i; j++) {
//            a.push_back(i);
//            b.push_back(j);
//        }
//    }
//
//    vector<ll> c = ask(a, b);
//    std::reverse(c.begin(), c.end());
//
//    vector<vector<bool>> cmp(n, vector<bool>(n, true));
//    for (ll i = 1; i < n; i++)
//        for (ll j = 0; j < i; j++) {
//            cmp[i][j] = c.back() == i;
//            cmp[j][i] = c.back() == j;
//            c.pop_back();
//        }
//
//    for (ll i = 0; i < n; i++) {
//        bool good = true;
//        for (ll j = 0; j < n; j++)
//            good = good and cmp[i][j];
//
//        if (good)
//            return i;
//    }
//    return 0;
//}

static vector<ll> p, q;

ll onlogn(ll n) {
    p.resize(n);
    std::iota(p.begin(), p.end(), 0);

    ll cnt = 0;
    while (n > 1) {
        cnt++;
        if (cnt > 20)
            return 0;

        q.resize(n);
        for (ll i = 0; i < n; i++)
            q[i] = p[(i + 1) % n];

        q = ask(p, q);

        p.clear();
        for (ll i = 0; i < n; i++) {
            if (q[i] == q[(i + 1) % n]) {
                p.push_back(q[i]);
                i++;
            }
        }
        n = p.size();
    }

    return p[0];
}

const ll MAX_N = 1e6;

ll richest(ll N, ll T, ll S) {
    ios_base::sync_with_stdio(false);
    if (p.capacity() < 1000) {
        p.reserve(MAX_N);
        q.reserve(MAX_N);
    }

//    if (T == 1) {
//        return on2(N);
//    } else {
        return onlogn(N);
//    }
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Wrong Answer
time: 1ms
memory: 8244kb

input:

1000 1 499500 957319859

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Pretest #2:

score: 0
Time Limit Exceeded

input:

1000000 20 2000000 29091473

output:

Unauthorized output

result:



Final Tests

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 8268kb

input:

1000 1 499500 957319857

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Test #2:

score: 0
Time Limit Exceeded

input:

1000000 20 2000000 29091471

output:

Unauthorized output

result: