#P11133. 【MX-X5-T5】「GFOI Round 1」World Ender

    ID: 11688 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>博弈论交互题Special JudgeO2优化梦熊比赛

【MX-X5-T5】「GFOI Round 1」World Ender

Background

Original link: https://oier.team/problems/X5F


The Border of Divinity.\small\text{The Border of \textbf{Divinity}}.

Problem Description

This is an interactive problem. Only C++ submissions are supported, and C++14 (GCC 9) is not supported.

Hikari and Tairitsu invented a new game using their glass shards.

There are nn piles of shards, numbered from 00 to n1n-1.

aa is a positive integer sequence of length nn with indices 0n10\sim n-1, where aia_i means the number of shards in pile ii.

They take turns to operate. Each move is as follows:

  • Choose a pile ii, take out at least one shard and discard it.
  • Then distribute the remaining shards in pile ii arbitrarily among all non-empty piles. In particular, you may put them back into the original pile.

Hikari goes first. The player who cannot make a move loses.

You will play as either Hikari or Tairitsu, and play against the other one.

Specifically, given a0,a1,,an1a_0, a_1, \ldots, a_{n-1}, you need to decide whether to be the first or second player, and then play this game on a0,a1,,an1a_0, a_1, \ldots, a_{n-1} with the interactive library.

Interaction Format

This problem uses multiple test cases and uses bundled judging.

Your program does not need to, and must not, include a main function.

You only need to implement the following 33 functions:

bool Init(int n, int op, std::vector<int> a);

  • This function is used for initialization and preprocessing.
  • Here nn is the number of piles as described, and opop is the subtask index.
  • aa is a std::vector<int> of length nn with indices 0n10\sim n-1, representing the sequence above.
  • You need to return a value in {0,1}\{0,1\}. Returning 00 means you choose to play first as Hikari, and returning 11 means you choose to play second as Tairitsu.

void Get(std::vector<int> a);

  • This function is used for your program to receive the sequence after the interactive library makes a move.
  • aa is a std::vector<int> of length nn, representing the resulting sequence after the library’s move.

std::vector<int> Play();

  • This function is used for your program to return the sequence after you make a move.
  • You need to return a std::vector<int> aa of length nn, representing the resulting sequence after your move.

Each test point contains multiple test cases. For each test case within a test point, the interaction process is:

  • Call Init() once.
  • If the contestant chooses to go first, call Play(); otherwise skip this step.
  • The library makes one move on aa and then calls Get().
  • Then the library alternates calling Play() and Get(), guaranteeing that in every two consecutive calls, exactly one is Play() and one is Get().
  • In particular, if after some Play() call the library moves aa into a terminal state, or if the library cannot move, then it will decide the result and terminate this test case, proceeding to the next one. That is, the library will not call Get() one more time at the end.

This problem will use a custom checker to score your interaction process. See [Scoring] for details。

Input Format

See [Notes / Hint]

Output Format

See [Notes / Hint]

2 0
10
1 1 4 5 1 4 1 9 1 9
2
1 1

AC

Hint

This problem uses multiple test cases.

[Sample Explanation]

The sample consists of two test cases.

In the first test case, choosing to go first as Hikari guarantees a win.

In the second test case, choosing to go second as Tairitsu guarantees a win.

[Notes / Hint]

The attachment provides grader.cpp and sample.cpp. sample.cpp is a sample contestant program, which you may build upon. grader.cpp is the provided interactive library. The strategy in the provided library is not the final library’s strategy, so your implementation must not rely on the library’s implementation.

You need to place your program game.cpp and grader.cpp in the same directory, and compile in that directory using the following command to obtain the executable game(.exe):

g++ -o game grader.cpp game.cpp -O2 -std=c++14

The executable reads input from standard input in the following format:

  • The first line contains two positive integers TT and opop, where TT is the number of test cases, and opop is the subtask index. Only the sample has op=0op=0.
  • For each test case, the input format is:
    • The first line contains a positive integer nn, the length of sequence aa.
    • The second line contains nn positive integers, representing a0,a1,,an1a_0,a_1,\ldots,a_{n-1}.

When testing locally, make sure your input and interaction format meet the requirements. Otherwise, we do not guarantee the interactive library will run correctly.

If your input and interaction format are valid and there is no runtime error, the provided interactive library will output:

  • AC if you successfully defeat the interactive library.
  • WA otherwise.

Your program must not read from or write to standard input/output. Otherwise it will be considered an attack on the interactive library.

[Scoring]

This problem will use a custom checker to score your interaction process. In each test point, if you exceed the time limit, exceed the memory limit, or encounter a runtime error, your score is 00. Otherwise, your score depends on your performance during interaction:

  • Parameter SS depends on your performance during interaction:
    • If in every test case of the test point, you always choose the correct first/second role and always defeat the interactive library, then S=1S=1.
    • If in every test case of the test point, you always choose the correct first/second role but make an invalid move or lose to the interactive library, then S=0.2S=0.2.
    • If in every test case of the test point, you choose the wrong first/second role at least once but still defeat the interactive library in all test cases, then if op{4,5}op\in \{4,5\}, S=1S=1; otherwise S=0.6S=0.6.
    • Otherwise, S=0S=0.
  • Your final score for this test point is S×scoreS\times score, where scorescore is the score of the subtask containing this test point.
  • Your final score for a subtask is the minimum score among all test points within that subtask.

[Constraints]

This problem uses bundled judging.

Subtask index (op=op =) nn\le aia_i\le Special property Score
11 33 22 None 55
22 1010 1515
33 100100 1010
44 20002000 A 1515
55 B 2020
66 None 3535
  • Special property A: The interactive library’s strategy is to choose a non-empty pile, take away some shards, and put the remaining shards back into the original pile.
  • Special property B: The interactive library’s strategy is to choose a non-empty pile, take away some shards, and put all remaining shards into a single pile (possibly the original pile).

For all data, 1T20001 \le T\le 2000, 1op61 \le op \le 6, 1n20001 \le n\le 2000, 1ai20001 \le a_i\le 2000, 1ai40001 \le \sum a_i \le 4000, 1n20001 \le\sum n\le 2000, 1ai40001 \le \sum\sum a_i\le 4000.

It is guaranteed that within each test point, the number of calls to Init() does not exceed 2000, and the total number of calls to Get() and Play() does not exceed 4000. When the contestant’s interaction format is correct, the running time of the interactive library itself is always no more than 500ms.

Translated by ChatGPT 5