QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#510378 | #9156. 百万富翁 | jamjanek | 100 ✓ | 3467ms | 106068kb | C++20 | 2.4kb | 2024-08-09 03:21:22 | 2024-08-09 03:21:22 |
Judging History
answer
#include "richest.h"
#include<bits/stdc++.h>
using namespace std;
int zlicz[1000010];
int na_raz(vector<int>X){
if(X.size()==1)return X[0];
vector<int>a,b;
for(int i=0;i<(int)X.size();i++)
for(int j=i+1;j<(int)X.size();j++){
a.push_back(X[i]);
b.push_back(X[j]);
}
vector<int>wynik = ask(a,b);
for(auto j: wynik)zlicz[j]=0;
for(auto j: wynik)zlicz[j]++;
for(auto j: wynik)
if(zlicz[j]==(int)X.size()-1)return j;
return 0;
}
map<pair<int,int>, long long>mapa;
map<pair<int,int>, int>strzalka;
long long policz(int n, int t){
if(mapa[{n, t}]!=0 || n==1)return mapa[{n, t}];
//printf("%d %d\n", n, t);
if(t==0)return 1000000000000;
mapa[{n,t}] = 1000000000000;
for(long long i=2;i<=n;i++){
long long pom = ((long long)n/i)*((i*(i-1))/2)+((long long)n%i)*(n%i-1)/2;
if(mapa[{n,t}]>(long long)policz((n+i-1)/i, t-1)+pom){
strzalka[{n,t}] = i;
mapa[{n,t}] = policz((n+i-1)/i, t-1)+pom;
}
}
return mapa[{n,t}];
}
//1099947
//2 2 2 2 3 6 19 182
//500000 250000 125000 62500 20833 3472 1
vector<int>podzial = {2, 2, 2, 2, 3, 6, 19, 182};
vector<int>podzial2 = {500000, 250000, 125000, 62500, 20833, 3472, 183, 1};
int richest(int n, int t, int s) {
if(s==2000000)s=1099947;
//policz(n,t);
vector<int>mozliwe;
int i;
for(i=0;i<n;i++)mozliwe.push_back(i);
if(t==1){
return na_raz(mozliwe);
}
for(auto pom: podzial2){
// printf("%d %d\n", pom, n);
vector<int>a,b;
vector<vector<int>>podzialy(pom);
for(i=0;i<(int)mozliwe.size();i++){
podzialy[i%pom].push_back(mozliwe[i]);
}
for(auto j: podzialy){
for(i=0;i<(int)j.size();i++)
for(int ij=i+1;ij<(int)j.size();ij++){
a.push_back(j[i]);
b.push_back(j[ij]);
}
}
vector<int>wynik = ask(a,b);
vector<int>nowe;
for(auto j: mozliwe)zlicz[j]=0;
for(auto j: wynik)zlicz[j]++;
for(auto j: podzialy){
for(auto ij: j){
if(zlicz[ij]==(int)j.size()-1){
nowe.push_back(ij);
}
}
}
s = s-a.size();/*
if(pom>2){
for(auto j: mozliwe)printf("%d ", j);printf("\n");
for(auto j: a)printf("%d ", j);printf("\n");
for(auto j: b)printf("%d ", j);printf("\n");
for(auto j: nowe)printf("%d ", j);printf("\n");
printf(" %d %d %d %d\n", n, pom, nowe.size(), (n+pom-1)/pom);
//return 0;
}*/
mozliwe = nowe;
n = mozliwe.size();
}
return mozliwe[0];
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 624ms
memory: 26032kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 3467ms
memory: 106024kb
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: 614ms
memory: 25100kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 3465ms
memory: 106068kb
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