QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#509711#9156. 百万富翁hztmax0100 ✓3007ms122684kbC++141.8kb2024-08-08 17:37:042024-08-08 17:37:05

Judging History

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

  • [2024-08-08 17:37:05]
  • 评测
  • 测评结果:100
  • 用时:3007ms
  • 内存:122684kb
  • [2024-08-08 17:37:04]
  • 提交

answer

#include "richest.h"
#include <algorithm>
#include <numeric>
#include <cassert>

using namespace std;

vector<int> get_max (vector<vector<int>> vec) {
  int t = vec.size();
  vector<int> a, b;
  for (int k = 0; k < t; ++k) {
    int cnt = vec[k].size();
    for (int i = 0; i < cnt; ++i) {
      for (int j = i + 1; j < cnt; ++j) {
        a.push_back(vec[k][i]), b.push_back(vec[k][j]);
      }
    }
  }
  vector<int> c = ask(a, b); 
  vector<int> res;
  for (int k = t - 1; ~k; --k) {
    int cnt = vec[k].size();
    vector<int> win(cnt);
    for (int i = cnt - 1; ~i; --i) {
      for (int j = cnt - 1; j > i; --j) {
        if (c.back() == a[c.size() - 1]) ++win[i];
        if (c.back() == b[c.size() - 1]) ++win[j];
        c.pop_back();
      }
    }
    res.push_back(vec[k][find(win.begin(), win.end(), cnt - 1) - win.begin()]);
  }
  reverse(res.begin(), res.end());
  return res;
}

int richest (int N, int T, int S) {
  if (N == 1000 && T == 1 && S == 499500) {
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    return get_max(vector<vector<int>>{v}).back();
  }
  else {
    assert(N == int(1e6) && T == 20 && S == int(2e6));
    const vector<int> point{500000, 250000, 125000, 62500, 20833, 3472, 183, 1};
    vector<int> now(N);
    iota(now.begin(), now.end(), 0);
    for (int i = 0; i < point.size(); ++i) {
      int cnt = now.size(), p = point[i], low = cnt / p, cur = 0; 
      vector<vector<int>> des(p);
      for (int j = 0; j < p; ++j) {
        for (int k = 0; k < low; ++k) {
          des[j].push_back(now[cur++]);
        }
      }
      for (int j = 0; cur < cnt; ++j) {
        des[j].push_back(now[cur++]);
      }
      now = get_max(des);
    }
    assert(now.size() == 1);
    return now.back();
  }
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 632ms
memory: 23704kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 3007ms
memory: 119020kb

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: 627ms
memory: 23256kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2974ms
memory: 122684kb

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