Lisp em SCU - 4490 (强大的map用法)
Time Limit: 1000 MS Memory Limit: 131072 K
Description
There are two lists and they may be intersected with each other.
You must judge if they are intersected and find the first node they have in common.
Input
The first line is the number of cases.
Each case consists of two lists.
Each list consists of multiple nodes.
Each node is represented by its address in memory.
So, a list may look like this:
0x233333 0x123456 0xabcdef1 0xffffff nil
nil is the end of the list.
All lists have no cycle.
The length of list is not larger than 4e5.
List can’t be empty.
Warn: huge input.
Output
“No” if they are not intersected.
“Yes Address”, if they are intersected, print “Yes” and the address of their first common node.
Sample Input
2
0x233333 0x123456 0xabcdef1 0xffffff nil
0x999999 0x332232 0xffffff nil
0x233333 0x123456 0xabcdef1 0xffffff nil
0x987654 0xafafaf 0xfffcccc 0xaaface nil
Sample Output
Yes 0xffffff
No
#include <map>
#include <math.h>
#include <string>
#include <vector>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
string s;
map<string,int>mp;
vector<string>a;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
s.clear();
a.clear();
mp.clear();
while(cin>>s&&s!="nil")
mp[s]=1;
while(cin>>s&&s!="nil")
if(mp[s]==1)
a.push_back(s);
if(a.size()==0)
printf("No\n");
else
cout<<"Yes"<<" "<<a[0]<<endl;
}
return 0;
}
Lisp em SCU - 4490 (强大的map用法)的更多相关文章
- Collection List Set和Map用法与区别
labels:Collection List Set和Map用法与区别 java 散列表 集合 Collection 接 口的接口 对 象的集合 ├ List ...
- ES6中Set 和 Map用法
JS中Set与Map用法 一.Set 1.基本用法 ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set 本身是一个构造函数,用来生成 Set 数据结构. ...
- sort函数(cmp)、map用法---------------Tju_Oj_2312Help Me with the Game
这道题里主要学习了sort函数.sort的cmp函数写法.C++的map用法(其实和数组一样) Your task is to read a picture of a chessboard posit ...
- C++中的STL中map用法详解(转)
原文地址: https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html C++中的STL中map用法详解 Map是STL的一个关联容器,它提供 ...
- C++:map用法及元素的默认值
C++:map用法 一.map基本用法 键值对 第一个参数为键的类型,第二个参数为值的类型. 源代码 #include <iostream> #include <string> ...
- c++ STL map 用法
map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据 处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时 ...
- std::map用法
STL是标准C++系统的一组模板类,使用STL模板类最大的好处就是在各种C++编译器上都通用. 在STL模板类中,用于线性数据存储管理的类主要有vector, list, map 等等.本文主要 ...
- STL map 用法
首先make_pair Pairs C++标准程序库中凡是"必须返回两个值"的函数, 也都会利用pair对象 class pair可以将两个值视为一个单元.容器类别map和mul ...
- map用法详解
转自:http://www.kuqin.com/cpluspluslib/20071231/3265.html Map是 STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在 ...
随机推荐
- MagicB.0—怎样设置电脑自动关机?
天太晚了,该睡觉了,可是你的东西也许正在下载,软件正在更新,总之电脑还有一些工作没有完成,又不需要你人为的守着,随他去吧!可是电脑已经工作了一天了,它也要休息一下,再者也不能浪费电力资源呀,那么就来使 ...
- 小程序 mcrypt加密拓展在php7.1 废弃 使用openssl替代方案
原加密方法 使用mcrypt //获得16位随机字符串,填充到明文之前 $random = $this->getRandomStr(); $text = $random . pack(" ...
- 彻底解决mysql中文乱码
mysql是我们项目中非常常用的数据型数据库.但是因为我们需要在数据库保存中文字符,所以经常遇到数据库乱码情况.下面就来介绍一下如何彻底解决数据库中文乱码情况. 1.中文乱码 1.1.中文乱码 cre ...
- pycharm显示行号
在PyCharm 里,显示行号有两种办法: 1,临时设置.右键单击行号处,选择 Show Line Numbers. 但是这种方法,只对一个文件有效,并且,重启PyCharm 后消失. 2,永久设置. ...
- MySQL join 用法
select column1, column2 from TABLE1 join TABLE2 on 条件 # select * from table1 join table2; #两个表合成一个se ...
- git中如何查看一个文件的修改(更新)历史
有些时候有些文件或文件夹被移除了, 或者更换了路径或被改名了, 想跟踪一下这个文件被修改(更新)的历史, 可以用如下命令: git log -p matser -- filename 格式是: git ...
- Python实现好友全头像的拼接
微信好友全头像 话不多说,直接上代码 import itchat import math import PIL.Image as Image import os itchat.auto_login() ...
- oracle客户端不需要配置tnsnames.ora文件直接连接服务器数据库
在以前的oracle使用过程中,想要在客户端连接到服务器时,都是在客户端中的tnsnames.ora文件配置如以下内容: adb = (DESCRIPTION = (ADDRESS_LIST = (A ...
- 记点事! oracle 调用外部命令
oracle执行系统命令 测试成功环境:windows XP+oracle 10g.window 2008 R2 + 11g 代码如下: www.2cto.com Sql代码 crea ...
- HDU 1686 Oulipo(KMP变形求子串出现数目(可重))
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1686 题目大意:给两个字符串A,B求出A中出现了几次B(计算重复部分). 解题思路:稍微对kmp()函 ...