QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#535107#9156. 百万富翁XZC0920100 ✓2237ms104564kbC++141.5kb2024-08-27 20:22:402024-08-27 20:22:40

Judging History

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

  • [2024-08-27 20:22:40]
  • 评测
  • 测评结果:100
  • 用时:2237ms
  • 内存:104564kb
  • [2024-08-27 20:22:40]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
#define sz(a) ((int)(a).size())
using namespace std;
const int N = 1e6 + 5;
int l[N], r[N];
int richest(int n, int t, int s) 
{
    if(t == 1) 
    {
        vector<int> a, b, c(n);
        for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) a.push_back(i), b.push_back(j);
        auto t = ask(a, b);
        for(auto u: t) if((++c[u]) == n - 1) return u;
        return 0;
    }
    vector<int> a(n); r[0] = -1;
    for(int i = 0; i < n; i++) a[i] = i;
    auto work = [&](int m) 
    {
        int ct = 0, x = sz(a) / m, y = sz(a) % m;
        for(int i = 1; i <= m - y; i++) ct++, l[ct] = r[ct - 1] + 1, r[ct] = l[ct] + x - 1;
        for(int i = 1; i <= y; i++) ct++, l[ct] = r[ct - 1] + 1, r[ct] = l[ct] + x;
        vector<int> b, d, c(n);
        for(int i = 1; i <= ct; i++) 
        {
            for(int j = l[i]; j <= r[i]; j++)
            {
                for(int k = j + 1; k <= r[i]; k++) 
                {
                    b.push_back(a[j]);
                    d.push_back(a[k]);
                }
            }
        }
        auto t = ask(b, d);
        for(auto u: t) c[u]++;
        vector<int> a2;
        for(int i = 1; i <= ct; i++) 
            for(int j = l[i]; j <= r[i]; j++) 
                if(c[a[j]] == r[i] - l[i]) a2.push_back(a[j]);
        a.swap(a2);
    };
    work(500000), work(250000), work(125000), work(62500), work(20833), work(3472), work(183), work(1);
    return a[0];
}

详细


Pretests

Pretest #1:

score: 15
Accepted
time: 618ms
memory: 21900kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2237ms
memory: 104564kb

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: 620ms
memory: 23076kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2219ms
memory: 103756kb

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