QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#688680 | #9156. 百万富翁 | KiharaTouma | 100 ✓ | 3327ms | 132664kb | C++14 | 2.1kb | 2024-10-30 12:28:14 | 2024-10-30 12:28:15 |
Judging History
answer
//qoj9156
#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
int richest(int n, int T, int s){
if(n == 1000){
vector<int> x, y;
x.clear();
y.clear();
static int cnt[1010];
memset(cnt, 0, sizeof(cnt));
for(int i = 0; i < n; ++ i){
for(int j = i+1; j < n; ++ j){
x.push_back(i);
y.push_back(j);
}
}
vector<int> res = ask(x, y);
for(int i : res){
++ cnt[i];
}
for(int i = 0; i < n; ++ i){
if(cnt[i] == n - 1){
return i;
}
}
} else {
vector<int> now, x, y, t[1000010];
static int cnt[1000010], inb[1000010];
for(int i = 0; i < n; ++ i){
now.push_back(i);
}
static int opt[9] = {
1,
183,
3472,
20832,
62496,
125000,
250000,
500000,
1000000
};
for(int i = 8; i >= 1; -- i){
x.clear();
y.clear();
for(int j = 0; j < opt[i-1]; ++ j){
vector<int> ().swap(t[j]);
}
for(int j = 0; j < opt[i]; ++ j){
t[j%opt[i-1]].push_back(now[j]);
inb[now[j]] = j % opt[i-1];
}
for(int j = 0; j < opt[i-1]; ++ j){
int k = t[j].size();
for(int p = 0; p < k; ++ p){
for(int q = p+1; q < k; ++ q){
x.push_back(t[j][p]);
y.push_back(t[j][q]);
}
}
}
memset(cnt, 0, sizeof(cnt));
vector<int> z = ask(x, y);
for(int i : z){
++ cnt[i];
}
vector<int> ().swap(now);
for(int j = 0; j < 1000000; ++ j){
if(cnt[j] == t[inb[j]].size() - 1){
now.push_back(j);
}
}
}
return now[0];
}
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 621ms
memory: 48736kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 3327ms
memory: 126680kb
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: 617ms
memory: 48752kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 3256ms
memory: 132664kb
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