| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 512 MB | 223 | 36 | 30 | 16.760% |
Anna and Bruno are archaeologists. They are investigating ruins in Iran.
Their tasks are as follows: Anna visits ruins and discovers artifacts, and Bruno analyzes the results in the base camp.
Their investigation is scheduled for Q(= 1 000) days. Every day, Anna sends the results to Bruno using a communication device. The results for each day is expressed as an integer X.
Anna can use the communication device once per day only. It can send a sequence of length N(= 150) consisting of 0 or 1.
However, it was broken. There are several broken places in the sequence of length N. For a broken place, it always sends the value 0 regardless of the actual set value. When Anna sends a sequence, she can see the positions of the broken places. But, Bruno does not know them. The positions of broken places and the number of broken places can change every day.
There is a danger that their investigation will be delayed. Because you are a candidate of a contestant of an international programming contest in Iran, Anna and Bruno ask you to write a program which sends the results of their investigation.
Write two programs which achieve the communication between Anna and Bruno.
At a place where the communication device works, the sequence S and the sequence A have the same value. At a broken place, the sequence A always has the value 0 regardless of the values of the sequence S .
You need to submit two files written by the same programming language.
The first file is either Anna.c or Anna.cpp. This file sets a sequence sent by Anna, and implements the following function. The program should include Annalib.h.
void Anna( int N, long long X, int K, int P[] )N is the length of the sequence to be sent.X is the integer to be sent.K is the number of broken places.P[] is a sequence of length K, describing the positions of broken places.In the function Anna, the following function must be called.
void Set( int pos, int bit )pos is the position of the place to be set. pos must be an integer between 0 and N − 1, inclusive. Note that the positions are counted from 0. If it is called with parameter outside this range, your program is considered as Wrong Answer[1]. It is not allowed to call this function more than once with the same parameter pos. If it is called more than once with the same parameter, your program is considered as Wrong Answer[2].bit is the value set to the pos-th position of the sequence. The value of bit must be either 0 or 1. If it is called with other parameters, your program is considered as Wrong Answer[3].The function Set must be called exactly N times in the function Anna. When function Anna terminates, if the number of times the function Set is called is different from N, your program is considered as Wrong Answer[4].
Your program is terminated if the function call by Anna is considered invalid.
The second file is either Bruno.c or Bruno.cpp. This file recovers the integer expressing the results of investigation, and implements the following function. The program should include Brunolib.h.
long long Bruno( int N, int A[] )N is the length of the sequence received by Bruno.A is an integer sequence of length N. It is the sequence received by Bruno.Bruno must recover the value of X, and return it.The sample grader reads the following data from the standard input.
When the program terminates successfully, the sample grader writes the following information to the standard output. (The quotation mark is not written actually.)
Wrong Answer [1],” and your program is terminated.Anna is not considered as Wrong Answer, the sample grader writes “Accepted” and the value of L∗. For the value of L∗, see Scoring.If your program is considered as several types of Wrong Answer, the sample grader reports only one of them.
Here is a sample input for grader and corresponding function calls. Note that the following example does not satisfy the constraints of this task because Q = 2, N = 3.
| Sample Input | Sample Calls | |||
|---|---|---|---|---|
| Call | Return | Call | Return | |
2 3 14 1 2 3 9 2 0 1 |
Anna(...) |
|||
Set(0,0) |
||||
| (none) | ||||
Set(1,0) |
||||
| (none) | ||||
Set(2,1) |
||||
| (none) | ||||
| (none) | ||||
Bruno(...) |
||||
| 14 | ||||
Anna(...) |
||||
Set(0,0) |
||||
| (none) | ||||
Set(1,1) |
||||
| (none) | ||||
Set(2,1) |
||||
| (none) | ||||
Bruno(...) |
||||
| 9 | ||||
Here the parameters for Anna(...), Bruno(...), Anna(...), Bruno(...) are as follows.
| Parameter | Anna(...) |
Bruno(...) |
Anna(...) |
Bruno(...) |
|---|---|---|---|---|
N |
3 | 3 | 3 | 3 |
X |
14 | 9 | ||
K |
1 | 2 | ||
P |
{2} | {0,1} | ||
A |
{0,0,0} | {0,0,1} |
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)