QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#502285 | #9156. 百万富翁 | phlap# | 0 | 331ms | 101644kb | C++20 | 1.4kb | 2024-08-03 03:03:19 | 2024-08-03 03:03:19 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
int richest(int n, int t, int s){
int block=sqrt(n);
vector<int> vec[block];
for(int i=0; i<n; i++) vec[i%block].push_back(i);
int lastguess[block];
int found[block], cnt=0;
memset(found, 0, sizeof found);
vector<int> query1, query2, result;
while(cnt<block){
query1.clear(), query2.clear(), result.clear();
for(int i=0; i<block; i++){
if(found[i]) continue;
lastguess[i]=vec[i][0];
for(int j=1; j<vec[i].size(); j++){
query1.push_back(vec[i][0]);
query2.push_back(vec[i][j]);
}
}
if(!query1.empty()) result=ask(query1, query2);
for(int i=0; i<block; i++) vec[i].clear();
for(auto i: result) if(i!=lastguess[i%block]) vec[i%block].push_back(i);
for(int i=0; i<block; i++) if(vec[i].empty()) found[i]=1, cnt++;
}
vector<int> final;
for(int i=0; i<block; i++) final.push_back(lastguess[i]);
query1.clear(), query2.clear(), result.clear();
for(int i=0; i<block; i++){
for(int j=0; j<i; j++) query1.push_back(final[i]), query2.push_back(final[j]);
}
result=ask(query1, query2);
int isless[n];
memset(isless, 0, sizeof isless);
for(int i=0; i<query1.size(); i++){
if(result[i]==query1[i]) isless[query2[i]]=1;
else isless[query1[i]]=1;
}
for(auto i: result) if(!isless[i]) return i;
return -1;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 0
Wrong Answer
time: 1ms
memory: 8148kb
input:
1000 1 499500 957319859
output:
Too many queries 1294109832092195181 0.000000 6906350380861515327
result:
points 0.0 Too many queries
Pretest #2:
score: 0
Wrong Answer
time: 331ms
memory: 101644kb
input:
1000000 20 2000000 29091473
output:
Too many total elements in queries 1469670942222006797 0.000000 6906350380861515327
result:
points 0.0 Too many total elements in queries
Final Tests
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8136kb
input:
1000 1 499500 957319857
output:
Too many queries 1294109832092195181 0.000000 6906350380861515327
result:
points 0.0 Too many queries
Test #2:
score: 0
Wrong Answer
time: 311ms
memory: 101516kb
input:
1000000 20 2000000 29091471
output:
Too many total elements in queries 1469670942222006797 0.000000 6906350380861515327
result:
points 0.0 Too many total elements in queries