luogu#P10832. [COTS 2023] 传 Mapa
[COTS 2023] 传 Mapa
Background
Translated from Izborne Pripreme 2023 (Croatian IOI/CEOI Team Selection) D2T1. .
Happy birthday to NaCly_Fish! (2024.7.28)
Due to limitations of the Luogu judging system (this problem requires run-twice), this problem cannot be judged.
Problem Description
You are given pairs of positive integers in . Similar to in C++, you can treat the first number of each pair as a "key" and the second number as a "value". It is guaranteed that all keys are distinct, and you can query the value by its key.
You want to send these pairs of positive integers, but due to bandwidth limits, you can only compress them into a string for transmission.
Write a program to compress these pairs of positive integers into a string; or, given the string you constructed, answer queries: for each given key, you must output the corresponding value.
Input Format
The first line contains a positive integer , indicating the data type. If , it is an encoding task; otherwise, it is a decoding task.
- When :
The second line contains an integer , the number of pairs.
The next lines each contain two positive integers , representing the key and the corresponding value.
- When :
The second line contains three positive integers , representing the number of pairs, the number of queries, and the length of the string.
The third line contains a string of length .
The next lines each contain one positive integer , the queried key.
Output Format
- When :
The first line contains a positive integer , the length of the string you constructed.
The second line contains the string you constructed.
- When :
Output lines, each containing one positive integer, the corresponding value.
1
3
2 10
3 3
5 7
7
1100111
2
3 2 7
1100111
5
3
7
3
Hint
Constraints
For of the testdata, it is guaranteed that:
- .
- , .
- .
- All are pairwise distinct.
Scoring
If your output format is incorrect or you do not answer the queries correctly, you get points.
Otherwise, let be the length of the string you output. Your score is determined by the following table:
| Score | |
|---|---|
Translated by ChatGPT 5