PAT甲题题解-1032. Sharing (25)-链表水题
#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)-链表水题的更多相关文章
- PAT甲题题解-1041. Be Unique (20)-水题
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789189.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PAT甲题题解-1050. String Subtraction (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...
- PAT甲题题解-1120. Friend Numbers (20)-水题
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789775.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- 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 ...
- 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 ...
- PAT 甲级 1032 Sharing (25 分)(结构体模拟链表,结构体的赋值是深拷贝)
1032 Sharing (25 分) To store English words, one method is to use linked lists and store a word let ...
- PAT 1032 Sharing[hash][链表][一般上]
1032 Sharing (25)(25 分) To store English words, one method is to use linked lists and store a word l ...
- 【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 ...
- 1032 Sharing (25分)
1032 Sharing (25分) 题目 思路 定义map存储所有的<地址1,地址2> 第一set存放单词1的所有地址(通过查找map) 通过单词二的首地址,结合map,然后在set中查 ...
随机推荐
- 乘风破浪:LeetCode真题_039_Combination Sum
乘风破浪:LeetCode真题_039_Combination Sum 一.前言 这一道题又是集合上面的问题,可以重复使用数字,来求得几个数之和等于目标. 二.Combination Sum ...
- 乘风破浪:LeetCode真题_037_Sudoku Solver
乘风破浪:LeetCode真题_037_Sudoku Solver 一.前言 这次我们对于上次的模型做一个扩展并求解. 二.Sudoku Solver 2.1 问题 2.2 分析与解决 这道题 ...
- C#中单问号(?)和双问号(??)的用法整理
1.单问号(?) 1.1 表示Nullable类型 C#2.0里面实现了Nullable数据类型 //A.比如下面一句,直接定义int为null是错误的,错误提示为无法将null转化成int,因为后者 ...
- UltraISO制作使用(服务器装机u盘制作)
1.准备工作: 1)U盘一个,需要格式化(大于4G,毕竟ISO文件就已经大于4G了) 2)CentOS7.1 iso文件一个(去这里下载:http://www.centoscn.com/) 3)Ult ...
- python string.md
string 包含用于处理文本的常量和类.string模块始于Python的最早版本. 2.0版本中, 许多之前只在模块中实现的函数被转移为string对象的方法. 之后的版本中, 虽然这些函数仍然可 ...
- Nowcoder 提高组练习赛-R1
https://www.nowcoder.com/acm/contest/172#question 单人报名300元,五人合报免费,于是就和学弟同学学长们组了一个三世同堂的队伍,高一的学长wzhqwq ...
- 矿难让显卡压了那么多货咋办?NV如是说
在苏州 GTC 开幕的几天前,英伟达刚刚遭遇了一次股价的腰斩. 近来加密货币的热度渐低,受到挖矿热潮照顾许多的英伟达「矿机」销量受到打击,甚至出现了严重的库存危机,加上近来刚刚发的 RTX20 系列显 ...
- 在ado.net中实现oracle存储过程调用两种方式
1.常规的存储过程调用 String or=ConfigurationManager.ConnectionStrings["conn"].ToString(); OracleC ...
- bat 传递超过10个参数(bat参数遍历)
批处理文件中可引用的参数为%0~%9, %0是指批处理文件的本身,也可以说是一个外部命令:%1~%9是批处理参数,也称形参:而替换形参的实参若超过了批处理文件中所规定数值(9个)且想在批处理文件中应用 ...
- 警惕ASP.NET MVC中的ValidateInputAttribute
最近在做一个ASP.NET MVC项目的时候发现,有一个Controller的Action死活都没法接收到从客户端提交过来的Html表单请求和数据,后来才发现是因为默认情况下ASP.NET MVC在执 ...