译自 8th Romanian Master of Informatics, RMI 2020 D1T1。。
不要 。
在文件头加入如下的语句:
#include <string>
void save_to_floppy(const std::string&);
这是一道通信题。
有一个长度为 的整数序列 ,其中元素两两不同。
有 个询问,形如:给定 ,求出 使得 。
请你将这个序列压缩成一个 串保存在软盘上,并只使用这个 串回答这些询问。
实现细节
你不需要,也不应该实现 main 函数。
你需要实现以下的函数:
void read_array(int subtask_id, const std::vector<int> &v);
std::vector<int> solve_queries(int subtask_id,
int N, const std::string &bits,
const std::vector<int> &a,
const std::vector<int> &b);
你可以调用以下的函数。
void save_to_floppy(const std::string &bits);
第一次运行
交互库将会调用 read_array 函数恰好一次。参数的含义:
随后,调用 save_to_floppy 函数恰好一次,传入一个 串,表示你要存储的信息。
第二次运行
交互库将会调用 solve_queries 函数恰好一次。参数的含义:
subtask_id:子任务编号。
N: 的长度。
bits:软盘上的信息。
a, b:每次询问的左右端点。
设有 次询问,返回一个长度为 的 std::vector<int> 表示每次询问的答案。