CF918B Radio Station 题解
Content
有 \(n\) 个形如 \(a_i.b_i.c_i.d_i\) 的 IP 地址。有 \(m\) 条命令,每条命令由一条字符串 \(s\) 和一个形如 \(p.q.r.s\) 的 IP 地址,你需要输出这个命令,并输出这个命令所指向的 IP 地址对应的名称。
数据范围:\(1\leqslant n,m\leqslant 1000,0\leqslant a_i,b_i,c_i,d_i,p,q,r,s\leqslant 255,1\leqslant|s|\leqslant 10\)。
Solution
这题乍一看有些高大上,但看到这个数据范围之后,我就认定了这道题目只需要 \(\mathcal{O}(nm)\) 的枚举就能够解决。具体怎么解决?很简单,输入完每一次命令,直接再在所有 \(n\) 个 IP 地址中一个一个去找,看是否有和当前命令的 IP 地址相等的,一旦碰到相等的就直接输出就好了。
Code
string name[1007];
int n, m, a[1007], b[1007], c[1007], d[1007];
int main() {
getint(n), getint(m);
_for(i, 1, n) {cin >> name[i]; scanf("%d.%d.%d.%d", &a[i], &b[i], &c[i], &d[i]);}
_for(i, 1, m) {
string tmpname; int tmpa, tmpb, tmpc, tmpd;
cin >> tmpname;
scanf("%d.%d.%d.%d;", &tmpa, &tmpb, &tmpc, &tmpd);
_for(j, 1, n)
if(tmpa == a[j] && tmpb == b[j] && tmpc == c[j] && tmpd == d[j]) {
cout << tmpname << ' ';
writeint(tmpa), putchar('.');
writeint(tmpb), putchar('.');
writeint(tmpc), putchar('.');
writeint(tmpd), putchar(';'), putchar(' '), putchar('#');
cout << name[j] << endl;
break;
}
}
return 0;
}
CF918B Radio Station 题解的更多相关文章
- Radio Station
B. Radio Station time limit per test: 2 seconds memory limit per test: 256 megabytes input: standa ...
- Codeforces Round #459 (Div. 2):B. Radio Station
B. Radio Station time limit per test2 seconds memory limit per test256 megabytes Problem Dsecription ...
- 【Codeforces Round #459 (Div. 2) B】 Radio Station
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map模拟一下映射就好了. [代码] #include <bits/stdc++.h> using namespace ...
- 【23.48%】【codeforces 723C】Polycarp at the Radio
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- cf723c Polycarp at the Radio
Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be re ...
- codeforces 723C : Polycarp at the Radio
Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...
- Codeforces 723C. Polycarp at the Radio 模拟
C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
- Codeforces Round #375 (Div. 2) C. Polycarp at the Radio 贪心
C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- [LeetCode 题解]: Maximum Subarray
前言 [LeetCode 题解]系列传送门: http://www.cnblogs.com/double-win/category/573499.html 1.题目描述 Find the c ...
随机推荐
- 【Tool】MySQL安装
MySQL安装 2019-11-07 14:30:32 by冲冲 本机 Windows7 64bit,MySQL是 mysql-8.0.18-winx64.zip. 1.官网下载 https:// ...
- 网络管理之命令行工具nmcli
参考Ubuntu官方文档和Red Hat,本文采用Google翻译. NETWORKMANAGER 简介 介绍 NetworkManager 提供的默认联网服务是一个动态网络控制和配置守护进程,它尝试 ...
- GIT Bash 简单讲解-git如何推/拉代码
GIT Bash 简单讲解 一. 注册/登录GIT账号 注册(或者登录) GitHub地址:https://github.com/ 注册不做详细的讲解,按照注册指示进行注册就可以 ...
- Anaconda 镜像配置
镜像源 清华大学: https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ 北京外国语大学: https://mirrors.bfsu.edu.cn/h ...
- IDEA 配置背景颜色(豆沙绿)
1. 定义方案名字(my color) Ctrl + Shift + a --> Color Scheme // 快捷定位配置 // 路径:File --> Settings --> ...
- fluidity install on Cluster
fluidity install on Cluster 1.编译器安装 gcc4.6 openmpi python HOME_PATH= /hpcdata1/xiaozhong/ 1.1.gmp &a ...
- 间断有限元h自适应处理方法
细分单元 function Hrefine2D(refineflag) 根据refineflag变量细分单元,其中refineflag变量大小为 [Kx1],需要细分单元标记为1,不需要单元为0. 根 ...
- NextDenovo 组装基因组
NextDenovo 是有武汉未来组团队开发出来用于组装ONT,Pacbio, HIFI (默认参数可对60-100X数据更有效),可通过correct--assemble对其进行组装.组装后,每个碱 ...
- ubuntu终端ls颜色配置
buntu中没有LS_COLORS,/etc/目录中也没有DIR_COLORS,所以这里使用dircolor命令加以解决 1. 利用dircolors命令,查看我们的系统当前的文件名称显示颜色的值,然 ...
- day8 基本数据类型之字典
day8 基本数据类型之字典 一.字典(dict) 1.用途: 2.定义方式:在{}内用逗号分隔开多个元素,每个元素都是key:value的形式,其中value可以使任意类型,而key必须是不可变类型 ...