#P10434. [JOIST 2024] 间谍 3 / Spy 3
[JOIST 2024] 间谍 3 / Spy 3
Description
Aoi and Bitaro are spies belonging to the National Information Bureau of JOI country. Their mission this time is to conduct undercover investigation into the IOI country. Bitaro infiltrates into the IOI country, while Aoi gives instructions to Bitaro from the JOI country.
Before the infiltration, Aoi and Bitaro obtained a map of the IOI country. The IOI country has cities, numbered from to . Moreover, there are roads in the IOI country, numbered from to . Road () connects city and city bidirectionally, with a length of . It is possible to travel between any pair of cities by passing some roads. Bitaro moves between cities in the IOI country by passing these roads. Additionally, there are investigation plans. The -th plan () involves investigating city in the IOI country.
All the information above were first given to both Aoi and Bitaro. Then, Bitaro proceeded with the infiltration into the IOI country.
Bitaro successfully evaded numerous pursuers, defeated assassins, and finally managed to infiltrate into city of the IOI country. However, due to the extremely difficult nature of the infiltration operation, Bitaro lost some of the information about the IOI country. Specifically, Bitaro lost information about the length of roads, namely the roads . In other words, Bitaro no longer knows the values of . Note that while Bitaro lost this information, Aoi still retains it.
Bitaro immediately reported to Aoi which road lengths' information he had lost.
To accomplish the mission, Bitaro wants to find a shortest path from city to each of the cities targeted by the investigation plans.
Aoi will send Bitaro a string where each character is either '0' or '1' to assist him. Due to the risk of interception, Aoi wants to minimize the content sent to Bitaro.
Write a program to implement Aoi's strategy for sending a string to Bitaro, given the information about the IOI country, the investigation plans, and the roads Bitaro lost information about. Also, write a program to implement Bitaro's strategy for finding the shortest paths given the information he possesses and the string sent by Aoi.
Implementation Details
You should submit files.
The first file is Aoi.cpp. This file is intended to implement Aoi's strategy and should implement the following functions. The program should include Aoi.h using the preprocessor directive #include.
std::string aoi(int N, int M, int Q, int K, std::vector<int> A, std::vector<int> B, std::vector<long long> C, std::vector<int> T, std::vector<int> X)
This function is called only once for each test case.
- The parameter is the number of cities in IOI Kingdom .
- The parameter is the number of roads in IOI Kingdom .
- The parameter is the number of investigation plans .
- The parameter is the number of roads that Bitaro lost the length information of, denoted by .
- The parameters are arrays of length . They mean the road () connects the city and the city bidirectionally, with a length of .
- The parameter is an array of length . It means the -th plan () involves investigating city .
- The parameter is an array of length . It indicates that Bitaro lost the length information of roads .
- The return value is the string that Aoi sends to Bitaro.
- Each character of the string must be either '0' or '1'. If this condition is not met, your program will be judged as Wrong Answer [1].
- The length of string must be at most . If this condition is not met, your program will be judged as Wrong Answer [2].
The second file is Bitaro.cpp. This file is intended to implement Bitaro's strategy and should implement the following functions. The program should include Bitaro.h using the preprocessor directive #include.
void bitaro(int N, int M, int Q, int K, std::vector<int> A, std::vector<int> B, std::vector<long long> C, std::vector<int> T, std::vector<int> X, std::string s)
This function is called only once after the function aoi is called.
- The parameter is the number of cities in IOI Kingdom .
- The parameter is the number of roads in IOI Kingdom .
- The parameter is the number of investigation plans .
- The parameter is the number of roads that Bitaro lost the length information of, denoted by .
- The parameters are arrays of length . They mean the road () connects the city and the city bidirectionally, with a length of .
- The parameter is an array of length . It means the -th plan () involves investigating city .
- The parameter is an array of length . It indicates that Bitaro lost the length information of roads .
- The argument is a string where each character is either '0' or '1', representing the string sent by Aoi to Bitaro.
Within Bitaro.cpp, your program can call the following function.
void answer(const std::vector<int> &e)
- In the -th call () to this function, you have to answer the shortest path from city 0 to city , which is the target of the -th investigation plan.
- The parameter
eis an array that represents the shortest path from city 0 to city . - Let be the length of the array
e. The elements are the indices of roads in the shortest path from city 0 to city , in the order of traversal. - If there are multiple possible shortest paths, any of them can be chosen as the answer.
- Each element of the parameter
emust be between 0 and . If this condition is not met, your program will be judged as Wrong Answer [3]. - The sequence of roads indicated by the argument
emust form a path from city 0 to city . More formally, it must satisfy the following conditions.- There exists a sequence of numbers such that
- .
- .
- The road (where ) connects city and city .
- If these conditions are not met, your program will be judged as Wrong Answer [4].
- There exists a sequence of numbers such that
- If the sequence of roads indicated by the argument
eis not the shortest path from city 0 to city among all paths starting from city 0 and ending at city , your program will be judged as Wrong Answer [5]. Here, the length of the path is defined as the sum of the lengths of the roads used. - The function
answermust be called exactly times. If the number of calls to the functionansweris not equal to at the end of the execution of the functionbitaro, your program will be judged as Wrong Answer [6].
Important Notices
- Your program can implement other functions for internal use, or use global variables. Submitted files will be compiled with the grader, and become a single executable file. All global variables and internal functions should be declared in an unnamed namespace to avoid confliction with other files. When it is graded, it will be executed as two processes of Aoi and Bitaro. The process of Aoi and the process of Bitaro cannot share global variables.
- Your program must not use the standard input and the standard output. Your program must not communicate with other files by any methods. However, your program may output debugging information to the standard error.
Compilation and Test Run
You can download an archive file from the contest webpage which contains the sample grader to test your program. The archive file also contains a sample source file of your program.
The sample grader is the file grader.cpp. In order to test your program, put grader.cpp, Aoi.cpp, Bitaro.cpp, Aoi.h, Bitaro.h in the same directory, and run the following command to compile your programs. Instead, you may run compile.sh contained in the archive file.
g++ -std=gnu++20 -O2 -o grader grader.cpp Aoi.cpp Bitaro.cpp
When the compilation succeeds, the executable file grader is generated.
Note that the actual grader is different from the sample grader. The sample grader will be executed as a single process, which will read input data from the standard input and write the results to the standard output and the standard error output.
Input Format
The sample grader reads the following data from the standard input.
Output Format
The sample grader outputs the following information to the standard output and the standard error output (quotes for clarity).
- If your program is judged as Wrong Answer [1], [2], [3], [4], or [6], the sample grader writes its type as "Wrong Answer [1]" in the standard error output. Nothing will be output to the standard output.
- If not, the length of the returned string from the function
aoiwill be output to the standard error output in the format "Accepted: 2024". Additionally, the length of the path in the -th call () to theanswerfunction will be output to -th line of the standard output. The sample grading program does not check whether the path is the shortest.
If your program meets the conditions of several types of Wrong Answer, the sample grader reports only one of them.
3 3
1 2 1
0 2 2
0 1 3
2
2 1
2
0 1
Hint
Sample Communication
Here is a sample input for the sample grader and corresponding function calls.
| Sample Input 1 | Call | Return value |
|---|---|---|
| $$\texttt{3 3}\ \texttt{1 2 1} \ \texttt{0 2 2} \ \texttt{0 1 3} \ \texttt{2} \ \texttt{2 1} \ \texttt{2} \ \texttt{0 1}$$ | aoi(3, 3, 2, 2, [1, 0, 0], [2, 2, 1], [1, 2, 3], [2, 1], [0, 1]) |
|
| ^ | "101001" |
|
bitaro(3, 3, 2, 2, [1, 0, 0], [2, 2, 1], [-1, -1, 3], [2, 1], [0, 1], "101001") |
||
answer([1]) |
||
answer([1, 0]) |
The shortest path from city 0 to city 1, is achieved either by traversing roads 1 and 0 in this order, or simply passing through road 2. Therefore, for the second call to the answer function in this sample, it is also acceptable to call answer([2]).
The file that can be downloaded from the contest site, sample-01-in.txt, corresponds to input example 1.
The files sample-01-in.txt and sample-02-in.txt included in the downloadable files from the contest site can be used as input for the sample grader.
Constraints
All input data satisfies the following conditions:
- .
- .
- .
- .
- ().
- ().
- ().
- ().
- ().
- ().
- ().
- You can travel from any city to any other city by traversing some roads.
- All input values are integers.
Grading
If your program is judged as any type of Wrong Answer [1] - [6] (see Implementation Details) or any type of runtime errors (TLE (Time Limit Exceeded), MLE (Memory Limit Exceeded), Abnormal End, etc.) in any of the test cases, your score is 0 points.
Otherwise, the grading is based on the maximum length of the returned string from the function aoi, denoted as , across all test cases for this task.
- If , the score is points.
- If , the score is 100 points.
Here, represents the largest integer that is not greater than .
京公网安备 11011102002149号