QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#490229#9156. 百万富翁Snowfall1462#47.000035 2147ms83904kbC++142.0kb2024-07-25 13:14:462024-07-25 13:14:47

Judging History

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

  • [2024-07-25 13:14:47]
  • 评测
  • 测评结果:47.000035
  • 用时:2147ms
  • 内存:83904kb
  • [2024-07-25 13:14:46]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
int richest(int N, int T, int S)
{
    if (N <= 1000)
    {
        vector<int> A, B, C;
        for (int i = 1; i < N; i++)
        {
            for (int j = 0; j < i; j++)
                A.emplace_back(i), B.emplace_back(j);
        }
        int fa[1010];
        memset(fa, 0, sizeof(fa));
        C = ask(A, B);
        for (int i = 0; i < A.size(); i++)
        {
            int x = A[i], y = B[i], z = C[i];
            if (z == x)
                fa[y] = x;
            else
                fa[x] = y;
        }
        for (int i = 0; i < N; i++)
        {
            if (!fa[i])
                return i;
        }
    }
    else
    {
        int lim = 200;
        vector<int> A;
        for (int i = 0; i < N; i++)
            A.emplace_back(i);
        while (A.size() >= lim)
        {
            int n = A.size();
            vector<int> QA, QB, Ans;
            QA.clear(), QB.clear(), Ans.clear();
            for (int i = 0; i + 1 < A.size(); i += 2)
                QA.emplace_back(A[i]), QB.emplace_back(A[i + 1]);
            Ans = ask(QA, QB);
            if (n & 1)
                Ans.emplace_back(A[n - 1]);
            A = Ans;
        }
        lim = A.size();
        map<int, int> inv;
        vector<int> QA, QB, Ans;
        for (int i = 0; i < lim; i++)
            inv[A[i]] = i;
        for (int i = 1; i < lim; i++)
        {
            for (int j = 0; j < i; j++)
                QA.emplace_back(A[i]), QB.emplace_back(A[j]);
        }
        Ans = ask(QA, QB);
        bool low[1010];
        memset(low, 0, sizeof(low));
        for (int i = 0; i < QA.size(); i++)
        {
            int x = QA[i], y = QB[i], z = Ans[i];
            if (z == x)
                low[inv[y]] = true;
            else
                low[inv[x]] = true;
        }
        for (int i = 0; i < lim; i++)
        {
            if (!low[i])
                return A[i];
        }
        return A[0];
    }
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 610ms
memory: 22960kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 32
Acceptable Answer
time: 2147ms
memory: 83904kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 32 / 85, maxt = 14, maxs = 1007380
1918061652399545483
0.376471
10835644069095093111

result:

points 0.376471 Partially correct Case 2, 32 / 85, maxt = 14, maxs = 1007380


Final Tests

Test #1:

score: 15
Accepted
time: 624ms
memory: 22936kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 32
Acceptable Answer
time: 2124ms
memory: 83828kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 32 / 85, maxt = 14, maxs = 1007380
1918061652399545483
0.376471
10835644069095093111

result:

points 0.376471 Partially correct Case 2, 32 / 85, maxt = 14, maxs = 1007380