QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#527206#9156. 百万富翁sumi007#15 2697ms170448kbC++142.7kb2024-08-22 11:58:252024-08-22 11:58:25

Judging History

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

  • [2024-08-22 11:58:25]
  • 评测
  • 测评结果:15
  • 用时:2697ms
  • 内存:170448kb
  • [2024-08-22 11:58:25]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int vis[2077][2077],bel[1000007],p[1000005],B,len; 
set<int> s[10];
vector<int> vec[10];
int richest(int N, int T, int S) {
    if(N==1000 && T==1 && S==499500){
        vector<int> a,b,c;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                a.pb(i),b.pb(j);
            }
        }
        c = ask(a,b);
        for(int i=0;i<c.size();i++){
            int u = a[i],v = b[i],w = c[i];
            if(u == w) vis[u][v] = 1,vis[v][u] = 0;
            else vis[u][v] = 0,vis[v][u] = 1;
        }
        int ans = 0;
        for(int i=0;i<N;i++){
            int ck = 1;
            for(int j=0;j<N;j++){
                if(i==j) continue;
                if(!vis[i][j]) ck = 0;
            }
            if(ck == 1){
                ans = i;
                break;
            }
        }
        return ans;
    }else{
        srand(time(0));
        B = 100000;
        for(int i=0;i<10;i++){
            int l = i*B,r = l+B-1;
            for(int j=l;j<=r;j++) s[i].insert(j),bel[j] = i;
        }
        while(1){
            for(int i=0;i<10;i++) {
                vec[i].clear();
                for(int x:s[i]) vec[i].pb(x);
                random_shuffle(vec[i].begin(),vec[i].end());
            }
            vector<int> a,b,c;
            for(int i=0;i<10;i++){
                for(int j=0;j+1<vec[i].size();j++){
                    int u = vec[i][j],v = vec[i][j+1];
                    a.pb(u),b.pb(v);
                }
            } 
            c = ask(a,b);
            for(int i=0;i<c.size();i++){
                int u = a[i],v = b[i],w = c[i];
                if(u == w) s[bel[b[i]]].erase(b[i]);
                else s[bel[a[i]]].erase(a[i]);
            }
            int chk = 1;
            for(int i=0;i<10;i++) chk = chk&(s[i].size()==1);
            if(chk) break;
        }
        vector<int> f,a,b,c;
        for(int i=0;i<10;i++) f.pb(*s[i].begin());
        for(int i=0;i<10;i++){
            for(int j=i+1;j<10;j++){
                a.pb(f[i]),b.pb(f[j]);
            }
        }
        c = ask(a,b);
        for(int i=0;i<c.size();i++){
            int u = a[i],v = b[i],w = c[i];
            if(u == w) vis[bel[u]][bel[v]] = 1;
            else vis[bel[v]][bel[u]] = 1;
        }
        int ans = 0;
        for(int i=0;i<10;i++){
            int ck = 1;
            for(int j=0;j<10;j++){
                if(i==j) continue;
                if(!vis[i][j]) ck = 0;
            }
            if(ck == 1){
                ans = i;
                break;
            }
        }
        ans = f[ans];
        return ans;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 660ms
memory: 37616kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Wrong Answer
time: 2685ms
memory: 169988kb

input:

1000000 20 2000000 29091473

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer


Final Tests

Test #1:

score: 15
Accepted
time: 635ms
memory: 37552kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Wrong Answer
time: 2697ms
memory: 170448kb

input:

1000000 20 2000000 29091471

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer