|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|4 초||512 MB||5||2||2||40.000%|
fYanee is a bird enthusiast. Since reading about IP over Avian Carriers (IPoAC), she has spent much of her time training a flock of intelligent parrots to carry messages over long distances.
Yanee’s dream is to use her birds to send a message M to a land far far away. Her message M is a sequence of N (not necessarily distinct) integers, each between 0 and 255, inclusive. Yanee keeps K specially-trained parrots. All the parrots look the same; Yanee cannot tell them apart. Each bird can remember a single integer between 0 and R, inclusive.
Early on, she tried a simple scheme: to send a message, Yanee carefully let the birds out of the cage one by one. Before each bird soared into the air, she taught it a number from the message sequence in order. Unfortunately, this scheme did not work. Eventually, all the birds did arrive at the destination, but they did not necessarily arrive in the order in which they left. With this scheme, Yanee could recover all the numbers she sent, but she was unable to put them into the right order.
To realize her dream, Yanee will need a better scheme, and for that she needs your help. Given a message M, she plans to let the birds out one by one like before. She needs you to write a program that will perform two separate operations:
You may assume that all parrots always arrive at the destination, and that each of them remembers the number it was assigned. Yanee reminds you once again that the parrots may arrive in any order. Note that Yanee only has K parrots, so the sequence of integers between 0 and R that you produce must contain at most K integers.
Write two separate procedures. One of them will be used by the sender (encoder) and the other by the receiver (decoder).
The overall process is shown in the following figure.
The two procedures you are to write are:
This procedure must encode the message M into a sequence of integers between 0 and R, inclusive, that shall be sent using the parrots. To report this sequence, your procedure encode must call the procedure send(a) for each integer a that you wish to give to one of the birds.
This procedure must recover the original message. To report it, your procedure decode must call the procedure output(b) for each integer b in the decoded message, in the correct order.
Note that R and K are not given as input parameters – please see the subtask descriptions below. In order to correctly solve a given subtask, your procedures must satisfy the following conditions:
In the last subtask, your score varies according to the ratio between the lengths of the encoded message and the original message.
Consider the case where N = 3, and M= [10, 30, 20].
Procedure encode(N,M), using some strange method, may encode the message as the sequence of numbers (7, 3, 2, 70, 15, 20, 3). To report this sequence, it should call the procedure send as follows:
Once all parrots reach their destination, assume we obtain the following list of transcribed numbers: (3, 20, 70, 15, 2, 3, 7). The procedure decode will then be called with N=3, L=7, and X= [3, 20, 70, 15, 2, 3, 7].
The procedure decode must produce the original message (10, 30, 20). It reports the result by calling the procedure output as follows.
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)