QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#489294#9156. 百万富翁Crying100 ✓2118ms105652kbC++141.5kb2024-07-24 19:21:002024-07-24 19:21:00

Judging History

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

  • [2024-07-24 19:21:00]
  • 评测
  • 测评结果:100
  • 用时:2118ms
  • 内存:105652kb
  • [2024-07-24 19:21:00]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
const int MAXN = 1e6;
int n,deg[MAXN]; vec a,b,c;
int cur;

void reset(){a.clear(); b.clear();}
void link(int x,int y){a.push_back(x); b.push_back(y);}

int tag[MAXN],arr[MAXN],len[MAXN],tot;

void solve(int cnt){
    tot = 0; for(int i=0;i<n;i++)if(!tag[i])arr[tot++] = i;
    for(int i=0;i<cnt;i++)len[i] = tot/cnt + (i<tot%cnt);
    reset();
    for(int i=0,sum=0;i<cnt;sum+=len[i],i++){
        for(int j=0;j<len[i];j++)for(int k=j+1;k<len[i];k++)link(arr[sum+j],arr[sum+k]);
    }
    c = ask(a,b); cur = 0;
    for(int i=0,sum=0;i<cnt;sum+=len[i],i++){
        for(int j=0;j<len[i];j++)deg[arr[sum+j]] = 0;
        for(int j=0;j<len[i];j++)for(int k=j+1;k<len[i];k++){
            int v = c[cur++];
            deg[v]++;
        }
        for(int j=0;j<len[i];j++)if(deg[arr[sum+j]] != len[i]-1)tag[arr[sum+j]] = 1;
    }
}

int richest(int N,int _,int __){
    n = N;
    if(n==1000){
        reset();
        for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)link(i,j);
        c = ask(a,b); cur = 0;
        fill(deg,deg+n,0);
        for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
            int v = c[cur++];
            deg[v]++;
        }
        for(int i=0;i<n;i++)if(deg[i] == n-1)return i;
        return -1;
    }
    fill(tag,tag+n,0);
    solve(n/2); solve(n/4); solve(n/8); solve(n/16); solve(20832); solve(3472); solve(183); solve(1);
    for(int i=0;i<n;i++)if(!tag[i])return i;
    return -1;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 597ms
memory: 26332kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2118ms
memory: 97796kb

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: 606ms
memory: 24552kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2092ms
memory: 105652kb

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