#P11133. 【MX-X5-T5】「GFOI Round 1」World Ender
【MX-X5-T5】「GFOI Round 1」World Ender
Background
Original link: https://oier.team/problems/X5F。
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 piles of shards, numbered from to .
is a positive integer sequence of length with indices , where means the number of shards in pile .
They take turns to operate. Each move is as follows:
- Choose a pile , take out at least one shard and discard it.
- Then distribute the remaining shards in pile 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 , you need to decide whether to be the first or second player, and then play this game on 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 functions:
bool Init(int n, int op, std::vector<int> a);
- This function is used for initialization and preprocessing.
- Here is the number of piles as described, and is the subtask index.
- is a
std::vector<int>of length with indices , representing the sequence above. - You need to return a value in . Returning means you choose to play first as Hikari, and returning 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.
- is a
std::vector<int>of length , 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>of length , 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 and then calls
Get(). - Then the library alternates calling
Play()andGet(), guaranteeing that in every two consecutive calls, exactly one isPlay()and one isGet(). - In particular, if after some
Play()call the library moves 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 callGet()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 and , where is the number of test cases, and is the subtask index. Only the sample has .
- For each test case, the input format is:
- The first line contains a positive integer , the length of sequence .
- The second line contains positive integers, representing .
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:
ACif you successfully defeat the interactive library.WAotherwise.
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 . Otherwise, your score depends on your performance during interaction:
- Parameter 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 .
- 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 .
- 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 , ; otherwise .
- Otherwise, .
- Your final score for this test point is , where 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 () | Special property | Score | ||
|---|---|---|---|---|
| None | ||||
| A | ||||
| B | ||||
| None | ||||
- 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, , , , , , , .
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