QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602618#9156. 百万富翁Littlelu15 663ms75212kbC++142.3kb2024-10-01 11:16:402024-10-01 11:16:40

Judging History

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

  • [2024-10-01 11:16:40]
  • 评测
  • 测评结果:15
  • 用时:663ms
  • 内存:75212kb
  • [2024-10-01 11:16:40]
  • 提交

answer

#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
int solve0(){
    vector<int> aska,askb,resp;
    int cnt=0;
    for(int i=0;i<1000;++i) for(int j=i+1;j<1000;++j){
        aska.push_back(i),askb.push_back(j),++cnt;
    }
    resp=ask(aska,askb);
    vector<int> to[1000],in(1000),out(1000),ans;
    for(int i=0;i<cnt;++i){
        if(resp[i]==aska[i]) to[askb[i]].push_back(aska[i]),in[aska[i]]++,out[askb[i]]++;
        else to[aska[i]].push_back(askb[i]),in[askb[i]]++,out[aska[i]]++;
    }
    for(int i=0;i<1000;++i) if(out[i]==0) return i;
    // queue<int> que;
    // for(int i=0;i<1000;++i) if(in[i]==0) que.push(i);
    // while(!que.empty()){
    //     int u=que.front();que.pop();
    //     ans.push_back(u);
    //     for(int v:to[u]){
    //         --in[v];
    //         if(in[v]==0) que.push(v);
    //     }
    // }
    // return ans[ans.size()-1];
}
int solve1(){
    int n=1000000,h=n;
    vector<int> asks(h);
    for(int i=0;i<h;++i) asks[i]=i;
    int aq=0;
    while(h!=1){
        // if(h>=300){
            int x2=-1,cnt=0;
            if(h%2==1) x2=h-1;
            vector<int> aska,askb,resp;
            for(int i=0;i<h/2;++i)
                aska.push_back(asks[i*2]),askb.push_back(asks[i*2+1]),++cnt;
            resp=ask(aska,askb);
            asks.clear();
            if(x2!=-1) asks.push_back(x2);
            for(int i=0;i<cnt;++i){
                if(resp[i]==aska[i]) asks.push_back(aska[i]);
                else asks.push_back(askb[i]);
            }
            aq+=cnt;
            h=asks.size();
        // }else{
        //     vector<int> aska,askb,resp;
        //     int cnt=0;
        //     for(int i=0;i<h;++i) for(int j=i+1;j<h;++j){
        //         aska.push_back(asks[i]),askb.push_back(asks[j]),++cnt;
        //     }
        //     // alex;
        //     resp=ask(aska,askb);
        //     map<int,int> out;
        //     for(int i=0;i<cnt;++i){
        //         if(resp[i]==aska[i]) out[askb[i]]++;
        //         else out[aska[i]]++;
        //     }
        //     int ans;
        //     for(int i=0;i<h;++i) if(out[asks[i]]==0) ans=asks[i];
        //     asks.resize(1);
        //     asks[0]=ans,h=1;
        // }
    }
    return asks[0];
}
int richest(int n,int t,int s){
    if(n==1000) return solve0();
    else return solve1();
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 628ms
memory: 23180kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Wrong Answer
time: 293ms
memory: 75212kb

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: 663ms
memory: 24852kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Wrong Answer
time: 297ms
memory: 75136kb

input:

1000000 20 2000000 29091471

output:

Wrong answer
4459638610240858557
0.000000
6906350380861515327

result:

points 0.0 Wrong answer