#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. sqlserver 镜像 断开连接 正在恢复+主机服务器关机用备用镜像

    如果主机坏了断开连接就用备机的镜像数据库 --主备互换,备机sql命令 USE master;   ALTER DATABASE test SET PARTNER FORCE_SERVICE_ALLO ...

  2. windows下mysql和linux下mysql主从配置

    1. linux下mysql安装版本5.6   windows下mysql版本5.7  不要问我为什么版本不一致  就是想这么搞 2. linux为主服务器   windows为从服务器 3.找到li ...

  3. Scala学习之路 (一)Scala的安装

    1.Scala下载 版本选择,看spark官网 http://spark.apache.org/docs/latest/ spark2.3.0版本是用2.11版本的Scala进行开发的,所以此处下载S ...

  4. 软件测试QA、QC、QM的关系与区别

    01概念上 QA:Quality Assurance (质量保证) QC:Quality Control (质量控制) QM:Quality Manage (质量管理) 02定义上 QA:为达到质量要 ...

  5. Centos7常见问题及解决方法

    1,在Centos7中用MariaDB代替了mysql数据库 2,mysql报错:/usr/sbin/mysqld:unknown variable 'default-character-set=ut ...

  6. OpenCV——使用多边形包围轮廓

  7. linux-如何快速替换IP

    导读 在Linux在做高可用的时候,经常会使用到虚拟IP.在windows上一个网卡可以配置两个IP,在Linux直接使用ip命令就可以添加了. 添加 ip address add 192.168.1 ...

  8. JAVA框架 Spring 和Mybatis整合(动态代理)

    一.使用传统方式的dao的书写方式,不建议.目前采用的是动态代理的方式交给mybatis进行处理. 首先回顾下动态代理要求: 1)子配置文件的中,namespace需要是接口的全路径,id是接口的方法 ...

  9. Recent papers on Action Recognition | 行为识别最新论文

    CVPR2019 1.An Attention Enhanced Graph Convolutional LSTM Network for Skeleton-Based Action Recognit ...

  10. SVN 错误收集

    一.the working copy is locked due to a previous error 解决办法:在 Cornerstone 右键本地工程 --> clean.