QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#505160#9156. 百万富翁JCY_100 ✓2417ms97892kbC++171.5kb2024-08-04 20:53:582024-08-04 20:53:59

Judging History

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

  • [2024-08-04 20:53:59]
  • 评测
  • 测评结果:100
  • 用时:2417ms
  • 内存:97892kb
  • [2024-08-04 20:53:58]
  • 提交

answer

#include "richest.h"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i128 = __int128;
using u128 = unsigned __int128;
template <typename T>
void chkmax(T &x, const T &y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, const T &y) {
  x = min(x, y);
}
void work(vector<int> &id, int x) {
  vector<int> nid(x), a, b;
  for (int i = 0; i < x; ++i) {
    for (int j = i; j < (int)id.size(); j += x) {
      for (int k = j + x; k < (int)id.size(); k += x) {
        a.emplace_back(id[j]);
        b.emplace_back(id[k]);
      }
    }
  }
  vector<int> c = ask(a, b), deg(id.size());
  for (int i = 0, p = 0; i < x; ++i) {
    for (int j = i; j < (int)id.size(); j += x) {
      for (int k = j + x; k < (int)id.size(); k += x) {
        if (c[p++] == id[j]) {
          ++deg[j];
        } else {
          ++deg[k];
        }
      }
    }
    int bst = i;
    for (int j = i + x; j < (int)id.size(); j += x)
      if (deg[j] > deg[bst]) bst = j;
    nid[i] = id[bst];
  }
  id = move(nid);
}
int richest(int n, int, int) {
  static constexpr int magic[] = {500000, 250000, 125000, 62496, 20832, 3472, 183, 1};
  vector<int> vec(n);
  iota(vec.begin(), vec.end(), 0);
  if (n == 1000) {
    work(vec, 1);
  } else {
    for (auto x : magic) work(vec, x);
  }
  return vec[0];
}
/*
g++ B.cpp grader.cpp -o B -std=c++14 -O2 -Wall -Wextra -Wshadow -g -fsanitize=address,undefined
*/
/*
1000000 20 2000000 0
*/

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 629ms
memory: 21912kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2417ms
memory: 97800kb

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: 25332kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2374ms
memory: 97892kb

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