CF918B.Radio Station
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name of each server. For simplicity, we'll assume that an nginx command is of form "command ip;" where command is a string consisting of English lowercase letter only, and ip is the ip of one of school servers.

Each ip is of form "a.b.c.d" where a, b, c and d are non-negative integers less than or equal to 255 (with no leading zeros). The nginx configuration file Dustin has to add comments to has m commands. Nobody ever memorizes the ips of servers, so to understand the configuration better, Dustin has to comment the name of server that the ip belongs to at the end of each line (after each command). More formally, if a line is "command ip;" Dustin has to replace it with "command ip; #name" where name is the name of the server with ip equal to ip.
Dustin doesn't know anything about nginx, so he panicked again and his friends asked you to do his task for him.
由于这群学生烧毁了广播站的设备,校方校长给他们布置了惩罚性任务。达斯汀的任务是为学校网站的 nginx 配置文件添加注释。学校共有 n 台服务器,每台服务器都有一个名称和一个 IP 地址(名称不一定唯一,但 IP 地址唯一)。达斯汀已知每台服务器的名称与 IP 地址。为简化问题,我们假设一条 nginx 命令的形式为 "command ip;",其中 command 是仅由小写英文字母组成的字符串,ip 是学校某台服务器的 IP 地址。

每个 IP 地址形如 "a.b.c.d",其中 a、b、c 和 d 均为不超过 255 的非负整数(且不带前导零)。达斯汀需要添加注释的 nginx 配置文件共包含 m 条命令。人们从不记忆服务器的 IP 地址,因此为了更清晰地理解配置,达斯汀需在每一行末尾(即每条命令之后)添加注释,注明该 IP 地址所对应的服务器名称。更准确地说:若某行为 "command ip;",则达斯汀需将其替换为 "command ip; #name",其中 name 是 IP 地址恰好等于 ip 的那台服务器的名称。
达斯汀对 nginx 完全不了解,于是再次陷入恐慌;他的朋友们便请你代他完成这项任务。
输入格式
The first line of input contains two integers n and m (1 ≤ n, m ≤ 1000).
The next n lines contain the names and ips of the servers. Each line contains a string name, name of the server and a string ip, ip of the server, separated by space (1 ≤ |name| ≤ 10, name only consists of English lowercase letters). It is guaranteed that all ip are distinct.
The next m lines contain the commands in the configuration file. Each line is of form "command ip;" (1 ≤ |command| ≤ 10, command only consists of English lowercase letters). It is guaranteed that ip belongs to one of the n school servers.
输入的第一行包含两个整数 n 和 m(1 ≤ n, m ≤ 1000)。
接下来的 n 行包含服务器的名称和 IP 地址。每行包含一个字符串 name(服务器名称)和一个字符串 ip(服务器 IP 地址),两者以空格分隔(1 ≤ ∣name∣ ≤ 10,且 name 仅由小写英文字母组成)。保证所有 ip 均互不相同。
接下来的 m 行包含配置文件中的命令。每行格式为 "command ip;"(1 ≤ ∣command∣ ≤ 10,且 command 仅由小写英文字母组成)。保证该 ip 属于给定的 n 个学校服务器之一。
输出格式
Print m lines, the commands in the configuration file after Dustin did his task.
输出 m 行,即 Dustin 完成其任务后配置文件中的命令。
输入输出样例
输入#1
2 2 main 192.168.0.2 replica 192.168.0.1 block 192.168.0.1; proxy 192.168.0.2;
输出#1
block 192.168.0.1; #replica proxy 192.168.0.2; #main
输入#2
3 5 google 8.8.8.8 codeforces 212.193.33.27 server 138.197.64.57 redirect 138.197.64.57; block 8.8.8.8; cf 212.193.33.27; unblock 8.8.8.8; check 138.197.64.57;
输出#2
redirect 138.197.64.57; #server block 8.8.8.8; #google cf 212.193.33.27; #codeforces unblock 8.8.8.8; #google check 138.197.64.57; #server
输入解题思路,AI测评打分。不知道怎么写?