QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#577484 | #9156. 百万富翁 | thomaswmy# | 100 ✓ | 2275ms | 87496kb | C++14 | 1.6kb | 2024-09-20 11:49:05 | 2024-09-20 11:49:07 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int n;
void query(vector<int> &arr,vector<pair<int,int> > &e) {
vector<int> x,y;
for(auto i:e) x.push_back(i.first),y.push_back(i.second);
vector<int> res=ask(x,y);
static bool vis[N];
memset(vis,0,sizeof(vis));
for(int i=0;i<e.size();i++) {
if(res[i]==x[i]) vis[y[i]]=1;
else vis[x[i]]=1;
}
vector<int> arrr;
for(int i:arr) if(!vis[i]) arrr.push_back(i);
arr=arrr;
}
void solve1(int len,vector<int> &arr) {
vector<pair<int,int> > e;
int sz=arr.size();
for(int i=0;i<sz;i+=len) {
assert(i+len<=sz);
for(int j=i;j<i+len;j++) for(int k=j+1;k<i+len;k++) e.push_back({arr[j],arr[k]});
}
query(arr,e);
}
void solve2(int len1,int cnt1,int len2,int cnt2,vector<int> &arr) {
vector<pair<int,int> > e;
int sz=arr.size();
for(int i=0,c=0;i<sz && c<cnt1;i+=len1,c++) {
for(int j=i;j<i+len1;j++) for(int k=j+1;k<i+len1;k++) e.push_back({arr[j],arr[k]});
}
for(int i=len1*cnt1,c=0;i<sz && c<cnt2;i+=len2,c++) {
for(int j=i;j<i+len2;j++) for(int k=j+1;k<i+len2;k++) e.push_back({arr[j],arr[k]});
}
query(arr,e);
}
int richest(int nn,int t,int s) {
n=nn;
vector<int> arr;
for(int i=0;i<n;i++) arr.push_back(i);
if(n==1000) {
solve1(arr.size(),arr);
return arr[0];
}
solve1(2,arr),solve1(2,arr),solve1(2,arr),solve1(2,arr);
solve2(3,20828,4,4,arr);
solve1(6,arr);
solve2(19,178,18,5,arr);
solve1(arr.size(),arr);
return arr[0];
}
/*
1099944
2 499951 2 49
2 249951 2 49
2 124951 2 49
2 62451 2 49
3 20828 4 4
6 3456 6 16
19 178 18 5
183 1 0 0
*/
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 629ms
memory: 27888kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2275ms
memory: 87496kb
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: 649ms
memory: 28408kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2207ms
memory: 87360kb
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