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. 从零开始学Kotlin第一课

    Kotlin的方法: 一个简单的计算器: fun main(args:Array<String>){ //主函数main方法 var a=8; var b=9; println(plus( ...

  2. 模数不超过 long long 范围时的快速乘

    笔者的话:使用前请确保评测系统的long double严格为16B ! 模数不在 int 范围内的乘法在 OI 中运用广泛,例如Millar-Rabin,Pollard-Rho等等.这样的乘法,直接乘 ...

  3. Codeforces 1137F - Matches Are Not a Child's Play(LCT)

    Codeforces 题面传送门 & 洛谷题面传送门 考虑将一个点 \(x\) 的编号变为当前所有点编号最大值 \(+1\) 会对每个点的删除时间产生怎么样的影响.由于编号最大的点肯定是最后一 ...

  4. Codeforces 285E - Positions in Permutations(二项式反演+dp)

    Codeforces 题目传送门 & 洛谷题目传送门 upd on 2021.10.20:修了个 typo( 这是一道 *2600 的 D2E,然鹅为啥我没想到呢?wtcl/dk 首先第一步我 ...

  5. R 小知识积累

    1.grep 1 ## a为一个data frame,取含有RNA-Seq的行 2 index <- grep("RNA-Seq", a$Assay_Type) 3 b &l ...

  6. 【宏基因组】MEGAN4,MEGAN5和MEGAN6的Linux安装和使用

    MEGAN(Metagenome Analyzer)是宏基因组学进行物种和功能研究的常用软件,实际上现在的Diamond+MEGAN6已经是一套比较完整的物种和功能注释流程了. 但是由于各种原因,我们 ...

  7. MySQL_集群

    管理节点:192.168.31.66 sql节点1+data1节点:192.168.31.42 sql节点2+data2节点:192.168.31.128 llll

  8. MapReduce07 Join多种应用

    目录 1 Join多种应用 1.1 Reduce Join 1.2 Reduce Join实例实操 需求 需求分析 Map数据处理 Reduce端合并(数据倾斜) 代码实现 JoinBean类 Joi ...

  9. abort, about

    abort 变变变: abortion:堕胎 abortionist:(非法)做堕胎手术的,不是所有的ist都是scientist, "All that glitters is not go ...

  10. day08 文件属性

    day08 系统目录 今日内容 一.重要目录 1./usr 2./var 3./proc 二.文件的属性 1.文件属性的介绍 2.文件属性的详述 3.企业案例 /usr 安装第三方软件的目录: 1./ ...