QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492313#9156. 百万富翁zfs732#68.99999 2064ms85232kbC++232.2kb2024-07-26 11:21:442024-07-26 11:21:46

Judging History

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

  • [2024-07-26 11:21:46]
  • 评测
  • 测评结果:68.99999
  • 用时:2064ms
  • 内存:85232kb
  • [2024-07-26 11:21:44]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>

int Force(std::vector<int> id) {
  int N = (int) id.size();
  std::vector g(N, std::vector<bool>(N));
  std::vector<int> A, B;
  for (int i = 0; i < N; i++)
    for (int j = i + 1; j < N; j++) {
      A.emplace_back(id[i]);
      B.emplace_back(id[j]);
    }
  auto res = ask(A, B);
  for (int i = 0, tot = 0; i < N; i++)
    for (int j = i + 1; j < N; j++) {
      int c = res[tot++] == id[i];
      g[i][j] = c, g[j][i] = !c;
    }
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    for (int j = 0; j < N; j++)
      cnt += g[i][j];
    if (cnt == N - 1)
      return id[i];
  }
  return -1;
}

int richest(int N, int T, int S) {
  std::vector<int> cur;
  for (int i = 0; i < N; i++)
    cur.emplace_back(i);

  if (T == 1) return Force(cur);

  for (int step = 0; step < 8; step++) {
    int m = (int) cur.size(), ext = -1;
    std::vector<int> A, B;

    for (int i = 0; i + 1 < m; i += 2) {
      A.emplace_back(cur[i]);
      B.emplace_back(cur[i ^ 1]);
    }

    if (m & 1) ext = cur.back();
    cur = ask(A, B);
    if (~ext) cur.emplace_back(ext);
  }

  {
    const int SI = 40;
    std::vector<int> A, B;
    int m = (int) cur.size();

    for (int l = 0; l < m; l++) {
      int r = std::min(l + SI, m) - 1;
      for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++) {
          A.emplace_back(cur[i]);
          B.emplace_back(cur[j]);
        }
      l = r;
    }

    std::vector<int> tmp;
    auto res = ask(A, B);

    int tot = 0;

    for (int l = 0; l < m; l++) {
      int r = std::min(l + SI, m) - 1, len = r - l + 1;
      std::vector g(m, std::vector<bool>(m));
      for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++) {
          int c = res[tot++] == cur[i];
          g[i][j] = c, g[j][i] = !c;
        }
      for (int i = l; i <= r; i++) {
        int cnt = 0;
        for (int j = l; j <= r; j++)
          cnt += g[i][j];
        if (cnt == len - 1)
          tmp.emplace_back(cur[i]);
      }
      l = r;
    }
    cur = tmp;
  }

  return Force(cur);
}

/*
 * 1000000 20 2000000 1
 * 998,046 + 1954
 */

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 620ms
memory: 25188kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 54
Acceptable Answer
time: 2064ms
memory: 85232kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1076857
15586462753811660969
0.635294
4439523384460221017

result:

points 0.635294 Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1076857


Final Tests

Test #1:

score: 15
Accepted
time: 614ms
memory: 23300kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 54
Acceptable Answer
time: 2057ms
memory: 85088kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1076857
15586462753811660969
0.635294
4439523384460221017

result:

points 0.635294 Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1076857