QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740596 | #9156. 百万富翁 | robertfan | 15 | 637ms | 30720kb | C++14 | 1.7kb | 2024-11-13 10:39:46 | 2024-11-13 10:39:47 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
int mp[8]={1,183,3472,20832,62500,125000,250000,500000};
int ok[1000006];
int dfs(vector<int>all,int t,int s){
if(all.size()==1){
return all[0];
}
vector<int>num;
int cnt=0;
vector<int>ve;
for(int i=0;i<all.size();i++){
cnt++;
num.push_back(all[i]);
if(cnt==mp[t-1]){
ve.push_back(dfs(num,t,s));
num.clear();
cnt=0;
}
}
if(num.size()){
ve.push_back(dfs(num,t-1,s));
}
int len=ve.size();
vector<int>a,b;
for(int i=0;i<len;i++){
for(int j=i+1;j<len;j++){
a.push_back(ve[i]);
b.push_back(ve[j]);
}
}
vector<int>ok(len);
vector<int>c=ask(a,b);
for(int i=0;i<len;i++){
ok[c[i]]++;
}
int ans=0;
for(int i=0;i<len;i++){
if(ok[ve[i]]==len-1){
ans= ve[i];
}
}for(int i=0;i<len;i++){
ok[c[i]]--;
}
return ans;
}
int richest(int N,int T,int S){
if(T==1){
vector<int>a,b;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
a.push_back(i);
b.push_back(j);
}
}
memset(ok,0,sizeof(ok));
vector<int>c=ask(a,b);
for(int i=0;i<c.size();i++){
ok[c[i]]++;
}
for(int i=0;i<N;i++){
if(ok[i]==N-1){
return i;
}
}
}
memset(ok,0,sizeof(ok));
vector<int>all;
for(int i=0;i<N;i++){
all.push_back(i);
}
return dfs(all,T,S);
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 625ms
memory: 30720kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 637ms
memory: 29680kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091471
output:
Unauthorized output