QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#641830 | #9156. 百万富翁 | huazai676 | 100 ✓ | 2607ms | 95352kb | C++17 | 1.5kb | 2024-10-15 01:10:08 | 2024-10-15 01:10:09 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<algorithm>
#include<random>
#include<vector>
#include "richest.h"
using namespace std;
typedef long long ll;
namespace
{
const int N=1e6+10;
int r[9]={1000000,500000,250000,125000,62496,20832,3472,183,1};
vector<int> seq,a,b;
bool vis[N];
int st[N],tp;
void init(int n)
{
seq.clear();
for(int i=0;i<n;i++) seq.push_back(i);
a.clear(),b.clear();
}
void clique(int l,int r)
{
for(int i=l;i<=r;i++)
for(int j=i+1;j<=r;j++)
a.push_back(seq[i]),b.push_back(seq[j]);
}
void Q()
{
vector<int> c=ask(a,b);
for(int i=0;i<c.size();i++) vis[st[++tp]=a[i]^b[i]^c[i]]=true;
vector<int> t;
for(int i:seq) if(!vis[i]) t.push_back(i);
swap(t,seq);
while(tp) vis[st[tp--]]=false;
a.clear(),b.clear();
}
}
int richest(int n,int T,int S)
{
init(n);
if(n==1000)
{
clique(0,n-1);
Q();
return seq[0];
}
else
{
for(int i=0;i<8;i++)
{
int t=r[i]/r[i+1];
int k=r[i]%r[i+1];
int l=0;
for(int j=0;j<(r[i+1]-k);j++)
{
clique(l,l+t-1);
l+=t;
}
for(int j=0;j<k;j++)
{
clique(l,l+t);
l+=t+1;
}
Q();
}
return seq[0];
}
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 624ms
memory: 25484kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2607ms
memory: 95352kb
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: 622ms
memory: 24540kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2563ms
memory: 94252kb
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