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用法)的更多相关文章

  1. Collection List Set和Map用法与区别

    labels:Collection List Set和Map用法与区别 java 散列表 集合 Collection           接 口的接口      对 象的集合   ├   List   ...

  2. ES6中Set 和 Map用法

    JS中Set与Map用法 一.Set 1.基本用法 ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set 本身是一个构造函数,用来生成 Set 数据结构. ...

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

  4. C++中的STL中map用法详解(转)

    原文地址: https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html C++中的STL中map用法详解   Map是STL的一个关联容器,它提供 ...

  5. C++:map用法及元素的默认值

    C++:map用法 一.map基本用法 键值对 第一个参数为键的类型,第二个参数为值的类型. 源代码 #include <iostream> #include <string> ...

  6. c++ STL map 用法

    map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据 处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时 ...

  7. std::map用法

    STL是标准C++系统的一组模板类,使用STL模板类最大的好处就是在各种C++编译器上都通用.    在STL模板类中,用于线性数据存储管理的类主要有vector, list, map 等等.本文主要 ...

  8. STL map 用法

    首先make_pair Pairs C++标准程序库中凡是"必须返回两个值"的函数, 也都会利用pair对象  class pair可以将两个值视为一个单元.容器类别map和mul ...

  9. map用法详解

    转自:http://www.kuqin.com/cpluspluslib/20071231/3265.html Map是 STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在 ...

随机推荐

  1. max-device-width和max-width的区别

    比如用媒体查询响应输出@media (max-width: 767px),用谷歌浏览器手机测试插件显示并无变化,其实关键在于max-device-width和max-width,以下摘抄↓ max-d ...

  2. Discrete Logging(POJ2417 + BSGS)

    题目链接:http://poj.org/problem?id=2417 题目: 题意: 求一个最小的x满足a^x==b(mod p),p为质数. 思路: BSGS板子题,推荐一篇好的BSGS和扩展BS ...

  3. HDU 1214 圆桌会议 (找规律)

    题目链接 Problem Description HDU ACM集训队的队员在暑假集训时经常要讨论自己在做题中遇到的问题.每当面临自己解决不了的问题时,他们就会围坐在一张圆形的桌子旁进行交流,经过大家 ...

  4. NYOJ 409 郁闷的C小加(三) (字符串处理)

    题目链接 描述 聪明的你帮助C小加解决了中缀表达式到后缀表达式的转换(详情请参考"郁闷的C小加(一)"),C小加很高兴.但C小加是个爱思考的人,他又想通过这种方法计算一个表达式的值 ...

  5. 使用SPLUNK进行简单Threat Hunting

    通过订阅网上公开的恶意ip库(威胁情报),与SIEM平台中网络流量日志进行匹配,获得安全事件告警. 比如,这里有一个malware urls数据下载的网站,每天更新一次: https://urlhau ...

  6. 安装ssh-keygen

    转载自:http://www.daoan.com/forums/index.php?forumid=5&mods=topicdisplay&postid=4 sudo apt-get ...

  7. 解决word2016鼠标每点击一下就出现一个保存的圆圈

    问题描述:今天打开word2016时,点击鼠标,随着鼠标会出现一个圆圈,让人看着很不习惯,通过查阅资料和亲自实践,记录在博客中. 由于自己之前装了PowerDesigner,PowerDesigner ...

  8. PHP用imageTtfText函数在图片上写入汉字

    https://blog.csdn.net/smstong/article/details/43955705 PHP绘图,imageString()这个函数并不支持汉字的绘制.这往往会给入门者当头一棒 ...

  9. Oracle中的dual

    简介,摘自百度百科: Oracle提供的最小的表,不论进行何种操作(不要删除记录),它都只有一条记录——'X'. 例如:执行select * from dual,里面只有一条记录:执行insert i ...

  10. zookeeper客户端连接报错

    [root@zoo1 zookeeper-3.4.10]# bin/zkCli.sh -server 172.16.1.10:2181 2017-10-27 00:37:59,326 [myid:] ...