QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#486971 | #9156. 百万富翁 | NOI_AK_ME | 0 | 0ms | 0kb | C++17 | 936b | 2024-07-22 14:23:43 | 2024-07-22 14:23:44 |
answer
#include <bits/stdc++.h>
#include "richest.h"
#define il inline
using namespace std;
il int sub1(int n,int tt,int ss,vector<int> a){
int x,y,z,u,v,w,m=0;for(int i=0;i<n;++i) m=max(m,a[i]);
vector<int> in(m,0),aska,askb,ret;
for(int i=0;i<n;++i) for(int j=i+1;j<n;++j) aska.push_back(a[i]),askb.push_back(a[j]);
ret=ask(aska,askb);x=ret.size();
for(int i=0;i<x;++i) ++in[ret[i]];
for(int i=0;i<n;++i) if(in[a[i]]==n-1) return a[i];
}
int richest(int n,int tt,int ss){
int x,y,z,u,v,w,m=0;vector<int> a,b,vis(n,0),aska,askb,ret;
for(int i=0;i<n;++i) a[i]=i;
while(a.size()>1){
m=a.size(),b.clear(),aska.clear(),askb.clear();
if(m<=512) return sub1(m,tt,ss,a);
for(int i=0;i<m-1;++i) aska.push_back(a[i]),askb.push_back(a[i+1]);
ret=ask(aska,askb);
for(int i=0;i<m-1;++i) if(ret[i]==aska[i]) vis[askb[i]]=1;else vis[aska[i]]=1;
for(int i=0;i<m;++i) if(!vis[a[i]]) b.push_back(a[i]);
a=b;
}
}
详细
Pretests
Pretest #1:
score: 0
Runtime Error
input:
1000 1 499500 957319859
output:
result:
Pretest #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091473
output:
result:
Final Tests
Test #1:
score: 0
Runtime Error
input:
1000 1 499500 957319857
output:
result:
Test #2:
score: 0
Runtime Error
input:
1000000 20 2000000 29091471