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的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在 ...
随机推荐
- 重构改善既有代码设计--重构手法11:Move Field (搬移字段)
你的程序中,某个字段被其所驻类之外的另一个类更多的用到.在目标类建立一个新字段,修改源字段的所有用户,令它们改用新字段. 动机:在类之间移动状态和行为,是重构过程中必不可少的措施.随着系 ...
- ⑥ 设计模式的艺术-06.建造者(Builder)模式
场景 我们要建造一个复杂的产品.比如:神州飞船,Iphone.这个复杂的产品的创建.有这样一个问题需要处理: 装配这些子组件是不是有个步骤问题? 实际开发中,我们所需要的对象构建时,也非常复杂,有很多 ...
- form表单有条件的提交
form表单提交数据,比如,积分,score,在0--100之间 var score = $('#score').val(); if(score !=''){ if(isNaN(score)){ la ...
- Redis数据类型之字符串(string)
1. string类型简介 string类型是二进制安全的,能够存储任意类型的字符串. string类型是最常用到的数据类型,一种常用的用法就是将对象格式化为JSON字符串然后放到redis中,取出来 ...
- Linux终端提示符PS1设置(颜色)
\d :代表日期,格式为weekday month date,例如:"Mon Aug 1"\H :完整的主机名称.例如:我的机器名称为:fc4.linux,则这个名称就是fc4.l ...
- Fiddler 抓包工具总结(转)
阅读目录 1. Fiddler 抓包简介 1). 字段说明 2). Statistics 请求的性能数据分析 3). Inspectors 查看数据内容 4). AutoResponder 允许拦截制 ...
- 多维尺度变换MDS(Multidimensional Scaling)
流形学习(Manifold Learning)是机器学习中一大类算法的统称,流形学习是非线性的降维方法(an approach to non-linear dimensionality reducti ...
- kernel随机生成MAC地址的接口
/** * eth_random_addr - Generate software assigned random Ethernet address * @addr: Pointer to a si ...
- React 16 源码瞎几把解读 【二】 react组件的解析过程
一.一个真正的react组件编译后长啥样? 我们瞎几把解读了react 虚拟dom对象是怎么生成的,生成了一个什么样的解构.一个react组件不光由若干个这些嵌套的虚拟dom对象组成,还包括各种生命周 ...
- tracert和traceroute使用
Traceroute提取发 ICMP TTL到期消息设备的IP地址并作域名解析.每次 ,Traceroute都打印出一系列数据,包括所经过的路由设备的域名及 IP地址,三个包每次来回所花时间. 转自 ...