QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#544088 | #9156. 百万富翁 | jay_jayjay# | 71.00004 | 2393ms | 86720kb | C++17 | 1.9kb | 2024-09-02 04:38:59 | 2024-09-02 04:38:59 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
int richest(int N, int T, int S) {
if(N<=1000) {
vector<int> a,b;
vector<int> occ(N);
for(int i=0;i<N;i++)for(int j=i+1;j<N;j++) a.push_back(i),b.push_back(j);
auto res = ask(a,b);
for(auto x:res)occ[x]++;
return max_element(all(occ)) - occ.begin();
}
//vector<int> p {2, 2, 2, 2, 5, 10, 20, (int)1e9};
//vector<int> p {2, 2, 2, 3, 11, 14, 81, (int)1e9};
vector<int> p{2, 2, 2, 2, 3, 6, 18, (int)1e9};
vector<int> pos(N);
for(int i=0;i<N;i++)pos[i]=i;
for(auto l : p) {
for(auto x:pos)assert(0<=x&&x<N);
int n = pos.size();
l=min(l, n);
//printf("%d %d\n",n,l);
if(l==1)break;
vector<int> a,b;
for(int z=0;z<n/l;z++) {
int i=z*l;
for(int j=0;j<l;j++)
for(int k=j+1;k<l;k++)
a.push_back(pos[i+j]),b.push_back(pos[i+k]);
}
auto res = ask(a,b);
vector<int> nx;
for(int i=n/l*l;i<n;i++) nx.push_back(pos[i]);
for(int i=0;i<n/l;i++) {
map<int,int> occ;
for(int j=0;j<l*(l-1)/2;j++)
occ[res[i*l*(l-1)/2+j]]++;
int mx=-1;
for(auto [x,y]:occ)if(y==l-1)mx=x;
assert(mx!=-1);
nx.push_back(mx);
}
swap(pos,nx);
}
//for(auto x:pos)printf("%d ",x);
//printf("return %d\n",pos[0]);
return pos[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 613ms
memory: 21868kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 56
Acceptable Answer
time: 2393ms
memory: 86720kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 56 / 85, maxt = 8, maxs = 1100136 1319216817707725215 0.658824 10645090175016484801
result:
points 0.658824 Partially correct Case 2, 56 / 85, maxt = 8, maxs = 1100136
Final Tests
Test #1:
score: 15
Accepted
time: 631ms
memory: 23116kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 56
Acceptable Answer
time: 2343ms
memory: 86660kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 56 / 85, maxt = 8, maxs = 1100136 1319216817707725215 0.658824 10645090175016484801
result:
points 0.658824 Partially correct Case 2, 56 / 85, maxt = 8, maxs = 1100136