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. CURL 简介【转载】

    转自http://hancang2010.blog.163.com/blog/static/1824602612010711104018261/ 0) 头信息 curl命令查询服务器头信息 curl ...

  2. Web应用程序完全测试指南

    随着Web技术和移动互联网的发展,越来越多的应用被迁移到了云端,这也使得用户可以随时随地使用它们.目前大量的优质应用,逐渐提升了用户的品味,也降低了用户的容忍度,如果你的Web应用无法使用户满意,那么 ...

  3. 【CodeForces】899 F. Letters Removing

    [题目]F. Letters Removing [题意]给定只含小写字母.大写字母和数字的字符串,每次给定一个范围要求删除[l,r]内的字符c(l和r具体位置随删除变动),求m次操作后的字符串.n&l ...

  4. 20155117王震宇 2006-2007-2 《Java程序设计》第5周学习总结

    教材学习内容总结 try & catch java中的错误会被打包成对象,可以尝试(try)捕捉(catch)代表错误的对象后做一些处理.如果发生错误,会跳到catch的区块并执行. 异常结构 ...

  5. session_write_close()的作用

    简单地说,当开启session_start以后,这个session会一直开启,并且被一个用户使用.其他用户开启session的话要等待第一个session用户关闭以后才可以开启sessio,这样就造成 ...

  6. MacOS Safari 中 button 不能使用 text-gradient

    @mixin text-gradient ($deg: 90deg, $from: $gradientFrom, $to: $gradientEnd) { background-image: line ...

  7. Linux下查看进程占用内存的最好方式

    今天看到stackoverflow上关于linux下如何查看某个进程占用的内存是多少的回答,觉得非常棒,不过是全英文的,很多人可能看不懂,所以我翻译一下 翻译自http://stackoverflow ...

  8. Spring是什么+控制反转和依赖注入

    Spring是一个开源框架,是一个轻量级的控制反转(IOC)和面向切面(AOP)的容器框架. 原因: (1)通过控制反转(IOC)达到松耦合,IOC也就是把控制权交出去,在使用中直接得到对象 (2)提 ...

  9. 【题解】BZOJ 3600: 没有人的算术——替罪羊树、线段树

    题目传送门 题意 具体的自己去上面看吧...反正不是权限题. 简单来说,就是定义了一类新的数,每个数是0或者为 \((x_L, x_R)\) ,同时定义比较大小的方式为:非零数大于零,否则按字典序比较 ...

  10. LNMP结合discuz的配置

    一.安装discuz 配置参照LAMP结合discuz的第一部分 不要忘记了 添加hosts~!!!! ===============我是分割线.========================== ...