QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#527102#9156. 百万富翁bribritt#66.999975 4032ms98028kbC++171.6kb2024-08-22 10:09:222024-08-22 10:09:22

Judging History

你现在查看的是最新测评结果

  • [2024-08-22 10:09:22]
  • 评测
  • 测评结果:66.999975
  • 用时:4032ms
  • 内存:98028kb
  • [2024-08-22 10:09:22]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXS = 1099944;
int buc[8] = {2,2,2,2,3,6,19,183};
int count(vector<int> &v, int x) {return upper_bound(v.begin(),v.end(),x)-lower_bound(v.begin(),v.end(),x);}
int rich(vector<int> v, int it) {
  int sz = v.size();
  if(sz==1) return v[0];
  assert(it<8);
  int bucket = buc[it];
  vector<int> a, b;
  for(int i=0;i<sz;i+=bucket) {
    for(int j=i;j<sz&&j<i+bucket;j++) for(int k=i;k<j;k++) a.push_back(v[j]),b.push_back(v[k]);
  }
  vector<int> c = ask(a,b);
  sort(c.begin(),c.end());
  vector<int> win;
  for(int i=0;i<sz;i+=bucket) {
    for(int j=i;j<sz&&j<i+bucket;j++) if(count(c,v[j])==min(bucket,sz-i)-1) win.push_back(v[j]);
  }
  return rich(win,it+1);
}
int richest(int N, int T, int S) {
  vector<int> v(N);
  iota(v.begin(),v.end(),0);
  return rich(v,0);
}
/*
int cdiv(int x, int y) {
  return (x-1)/y+1;
}
pair<long long,int> dp[9][1000005];
main() {
  // is x = ceil(1e6 / y) for some y?
  // x >= 1e6 / y
  // y >= 1e6 / x
  // check first value
  dp[0][1]={0,1};
  for(int i=2;i<1000005;i++) dp[0][i]={1000000000,1};
  for(int i=1;i<9;i++) for(int j=1;j<1000005;j++) if(j==cdiv(1000000,cdiv(1000000,j))) {
    dp[i][j]={dp[i-1][j].first,1};
    for(int k=2;k<=j;k++) dp[i][j]=min(dp[i][j],{dp[i-1][cdiv(j,k)].first+1LL*(k-1)*j,k});
  }
  cout << dp[8][1000000].first << "\n";
  for(int x=1000000,i=9;x>1;) {
    cout << "div by "<<dp[--i][x].second << "\n";
    x = cdiv(x,dp[i][x].second);
    cout << "x = " << x << "\n";
  }
}
// 1000000 (0)
// 500000 (500000)
// 250000 (750000)
// 125000 (875000)
// 62500 (937500)
*/

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Wrong Answer
time: 0ms
memory: 8156kb

input:

1000 1 499500 957319859

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Pretest #2:

score: 67
Acceptable Answer
time: 4018ms
memory: 97980kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960
2586970244946203279
0.788235
12006835993993373281

result:

points 0.788235 Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960


Final Tests

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 8104kb

input:

1000 1 499500 957319857

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Test #2:

score: 67
Acceptable Answer
time: 4032ms
memory: 98028kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960
2586970244946203279
0.788235
12006835993993373281

result:

points 0.788235 Partially correct Case 2, 67 / 85, maxt = 8, maxs = 1099960