luogu#P10832. [COTS 2023] 传 Mapa

    ID: 10611 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2023交互题Special JudgeO2优化高斯消元COCI(克罗地亚)通信题拉格朗日插值法

[COTS 2023] 传 Mapa

Background

Translated from Izborne Pripreme 2023 (Croatian IOI/CEOI Team Selection) D2T1. 1s,0.5G\texttt{1s,0.5G}.

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 NN pairs of positive integers in [1,109][1,10^9]. Similar to std::map<int,int>\texttt{std::map<int,int>} 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 NN pairs of positive integers, but due to bandwidth limits, you can only compress them into a 01\texttt{01} string for transmission.

Write a program to compress these NN pairs of positive integers into a 01\texttt{01} string; or, given the 01\texttt{01} string you constructed, answer QQ queries: for each given key, you must output the corresponding value.

Input Format

The first line contains a positive integer T{1,2}T\in \{1,2\}, indicating the data type. If T=1T=1, it is an encoding task; otherwise, it is a decoding task.

  • When T=1T=1:

The second line contains an integer NN, the number of pairs.

The next NN lines each contain two positive integers xi,yix_i,y_i, representing the key and the corresponding value.

  • When T=2T=2:

The second line contains three positive integers N,Q,KN,Q,K, representing the number of pairs, the number of queries, and the length of the 01\texttt{01} string.

The third line contains a 01\texttt{01} string of length KK.

The next QQ lines each contain one positive integer xix_i, the queried key.

Output Format

  • When T=1T=1:

The first line contains a positive integer KK, the length of the 01\texttt{01} string you constructed.

The second line contains the 01\texttt{01} string you constructed.

  • When T=2T=2:

Output QQ 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 100%100\% of the testdata, it is guaranteed that:

  • T{1,2}T\in \{1,2\}.
  • 1N,Q1001\le N,Q\le 100, 1K60001\le K\le 6\, 000.
  • 1xi,yi1091\le x_i,y_i\le 10^9.
  • All xix_i are pairwise distinct.

Scoring

If your output format is incorrect or you do not answer the queries correctly, you get 00 points.

Otherwise, let KK be the length of the 01\texttt{01} string you output. Your score is determined by the following table:

KK Score
K>6000K\gt 6\, 000 00
3000K60003\, 000\le K\le 6\, 000 100K300030\displaystyle 100- \frac{K-3\, 000}{30}
K3000K\le 3\, 000 100100

Translated by ChatGPT 5