#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <cmath>
using namespace std;
/*
链表题

*/
int n; struct Word{
int addr;
char ch;
int next=-;
}word[];
int vis[];
int main()
{
int first1,first2;
int adr,nxt;
char ch;
scanf("%d %d %d",&first1,&first2,&n);
for(int i=;i<n;i++){
scanf("%d %c %d",&adr,&ch,&nxt);
word[adr].addr=adr;
word[adr].ch=ch;
word[adr].next=nxt;
}
memset(vis,,sizeof(vis));
while(first1!=-){
vis[first1]=;
first1=word[first1].next;
}
bool flag=false;
while(first2!=-){
if(vis[first2]){
flag=true;
break;
}
first2=word[first2].next;
}
if(flag)
printf("%05d\n",first2);
else
printf("-1\n");
return ;
}

PAT甲题题解-1032. Sharing (25)-链表水题的更多相关文章

  1. PAT甲题题解-1041. Be Unique (20)-水题

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789189.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  2. PAT甲题题解-1050. String Subtraction (20)-水题

    #include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...

  3. PAT甲题题解-1120. Friend Numbers (20)-水题

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789775.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  4. PAT Advanced 1032 Sharing(25) [链表]

    题目 To store English words, one method is to use linked lists and store a word letter by letter. To s ...

  5. PAT甲 1032. Sharing (25) 2016-09-09 23:13 27人阅读 评论(0) 收藏

    1032. Sharing (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To store Engl ...

  6. PAT 甲级 1032 Sharing (25 分)(结构体模拟链表,结构体的赋值是深拷贝)

    1032 Sharing (25 分)   To store English words, one method is to use linked lists and store a word let ...

  7. PAT 1032 Sharing[hash][链表][一般上]

    1032 Sharing (25)(25 分) To store English words, one method is to use linked lists and store a word l ...

  8. 【PAT】1032 Sharing (25)(25 分)

    1032 Sharing (25)(25 分) To store English words, one method is to use linked lists and store a word l ...

  9. 1032 Sharing (25分)

    1032 Sharing (25分) 题目 思路 定义map存储所有的<地址1,地址2> 第一set存放单词1的所有地址(通过查找map) 通过单词二的首地址,结合map,然后在set中查 ...

随机推荐

  1. Linux运维之系统性能---vmstat工具分析内存的瓶颈

    为了提高磁盘存取效率, Linux做了一些精心的设计, 除了对dentry进行缓存(用于VFS,加速文件路径名到inode的转换), 还采取了两种主要Cache方式:Buffer Cache和Page ...

  2. LAMP平台的搭建及应用

    实验要求 1.构建PHP运行环境,实现LAMP协同架构,前提条件是服务器中已经编译好了Apache HTTP Server和MySQL数据库,(编译安装apache和编译安装mysql 请查看公众号L ...

  3. ActiveX多线程回调JavaScript

    http://www.cnblogs.com/zdxster/archive/2011/01/27/1945872.html

  4. Windows Server 2012上安装.NET Framework 3.5

    引用:https://jingyan.baidu.com/article/14bd256e26b714bb6d26128a.html 装不成功后网上搜到很多相同的问题,都尝试过没解决到 用PowerS ...

  5. 技术分享之AQS——内容提要

    1. 背景 最近团队内部技术分享,我做了个关于AQS的分享.ppt中涵盖的部分要点内容,现在整理到博客上. 关于AQS本身的源码解读,可以参考我之前的博文. 2. 要点梳理 下面是一些技术分享的要点梳 ...

  6. 小程序报错数据传输长度为 xxx 已经超过最大长度 xxx

    这个错误通常在通过base64给images赋值时发生,setData()微信设置的一次最大传输长度为1M,所有如果编码后的base64字符串长度超过了1M就会报这个错误. 如何解决? 我们可以采取曲 ...

  7. HTML5中的Canvas详解

    什么是Canvas HTML5 <canvas> 元素用于图形的绘制,通过脚本 (通常是JavaScript)来完成.<canvas> 标签只是图形容器,您必须使用脚本来绘制图 ...

  8. yield协程

    1.Generator Generator , 一种可以返回迭代器的生成器,当程序运行到yield的时候,当前程序就唤起协程记录上下文,然后主函数继续操作,当需要操作的时候,在通过迭代器的next重新 ...

  9. 构造方法,this关键字,static关键字,封装

    1.构造方法 定义:构造方法是指实例化对象的方法 语法:[修饰符]  类名(参数){    } 根据有无参数分为有参构造和无参构造 1)有参构造 语法:[修饰符]  类名(type 实例变量,int ...

  10. 关于 clock tree

    1.  create_clock 时,不要定义在 hierarchical pin 上,否则 cts 时会忽略这个 clock ,详见 CTS-811  Warning,解法是将其定义到实际存在的 p ...