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 题解的更多相关文章

  1. Radio Station

    B. Radio Station time limit per test:  2 seconds memory limit per test:  256 megabytes input: standa ...

  2. Codeforces Round #459 (Div. 2):B. Radio Station

    B. Radio Station time limit per test2 seconds memory limit per test256 megabytes Problem Dsecription ...

  3. 【Codeforces Round #459 (Div. 2) B】 Radio Station

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map模拟一下映射就好了. [代码] #include <bits/stdc++.h> using namespace ...

  4. 【23.48%】【codeforces 723C】Polycarp at the Radio

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. cf723c Polycarp at the Radio

    Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be re ...

  6. codeforces 723C : Polycarp at the Radio

    Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...

  7. Codeforces 723C. Polycarp at the Radio 模拟

    C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...

  8. 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 ...

  9. [LeetCode 题解]: Maximum Subarray

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Find the c ...

随机推荐

  1. Spring Cloud Gateway过滤器精确控制异常返回(分析篇)

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 在<Spring Cloud Gate ...

  2. 直接插入100w数据报错

    ### Cause: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (77,600 ...

  3. 从零开始学Kotlin第六课

    Kotlin调用java代码: 1.如果是内部工程的类,直接调用,如果是外部的工程项目按照java的方式将jar包导入进来. 2.实例化java对象 我们之前学java的时候实例化对象是这个样子的. ...

  4. Orika - 类复制工具

    Orika 前言 类复制工具有很多,比较常用的有 mapstruct.Spring BeanUtils.Apache BeanUtils.dozer 等,目前我所在的项目组中使用的是 mapstruc ...

  5. SimpleNVR安防监控RTSP/FLV/HLS直播流服务如何分权限添加用户指定通道观看

    背景分析 随着SimpleNVR的用户越来越多,很多客户反馈给了我们很宝贵的简易以及用户体验.在此非常感谢大家对我们的支持.其中很多客户不想把所有的视频直播展现出来,想分权限添加新用户,指定通道让其观 ...

  6. Codeforces 407E - k-d-sequence(单调栈+扫描线+线段树)

    Codeforces 题面传送门 & 洛谷题面传送门 深感自己线段树学得不扎实-- 首先特判掉 \(d=0\) 的情况,显然这种情况下满足条件的区间 \([l,r]\) 中的数必须相同,双针扫 ...

  7. 自助分析工具Power BI的简介和应用

    作为一名资深的IT技术人,特别喜欢学习和尝试新技术,也勇于接受挑战,勇于创新,不仅能发现问题,更要解决实际的疑难杂症,闲暇时光也乐于分享一些技术干货.记得2017年的时候,华章出版社的编辑通过网上找到 ...

  8. Excel-电话号码隐藏某几个数为*,起到保护信息作用;

    9.电话号码隐藏某几个数为*,起到保护信息作用: 方法一: =SUBSTITUTE(AG2,MID(AG2,4,5),"*****") 解释函数: MID(目标字符串,裁剪起始位置 ...

  9. jmeter非GUI(cmd命令行)模式的压测和输出测试报告

    1.非GUI模式的压测,和GUI有啥不同? 2.非GUI模式怎么搞? 大家打开jmeter的时候,都会看到这个界面: 注意看这句话: Don't use GUI mode for load testi ...

  10. JSP内置对象之out对象

    一.       JSP内置对象的概述     由于JSP使用java作为脚本语言,所以JSP将具有强大的对象处理能力,并且可以动态地创建Web页面内容.但Java语法在使用一个对象前,需要先实例化这 ...