九度oj 题目1468:Sharing 【ZJU2012考研机试题2】
来源:互联网 发布:广州淘宝运营培训 编辑:程序博客网 时间:2024/05/03 21:32
/************************************************************** Problem: 1468 Language: C++ Result: Accepted Time:190 ms Memory:1800 kb****************************************************************/#include <stdio.h>#include<string.h>const int MAX=100010;int hash[MAX];int mark[MAX];int main(){ int a,b,c,d,n,i; char e; //freopen("G:\\in.txt","r",stdin); while(scanf("%d%d%d",&a,&b,&n)!=EOF){ int start1=a; int start2=b; for(i=0;i<n;i++){ scanf("%d %c %d",&c,&e,&d); hash[c]=d; } for(i=0;i<MAX;i++) mark[i]=0; int id1=start1,id2=start2; while(id1!=-1){ mark[id1]=1; id1=hash[id1]; } while(id2!=-1){ if(mark[id2]==1){ printf("%05d\n",id2); break; } else id2=hash[id2]; } if(id2==-1) printf("-1\n"); } return 0;}
0 0
- 九度oj 题目1468:Sharing 【ZJU2012考研机试题2】
- 九度oj 题目1464:Hello World for U 【ZJU2012考研机试题1】
- 九度OJ 题目1468:Sharing
- 九度OJ-题目1468-Sharing-链表
- 九度oj 题目1016:火星A+B 【ZJU2006考研机试题2】
- 九度oj 题目1021:统计字符 【ZJU2007考研机试题2】
- 九度oj 题目1027:欧拉回路 【ZJU2008考研机试题2】
- 九度oj 题目1032:ZOJ 【ZJU2009考研机试题2】
- 九度oj 题目1006:ZOJ问题 【ZJU2010考研机试题2】【容易理解混乱】
- 九度oj 题目1002:Grading 【ZJU2011考研机试题2】
- 九度oj 题目1015:还是A+B 【ZJU2006考研机试题1】
- 九度oj 题目1017:还是畅通工程 【ZJU2006考研机试题3】
- 九度oj 题目1018:统计同成绩学生人数 【ZJU2006考研机试题4】
- 九度oj 题目1019:简单计算器 【ZJU2006考研机试题5】
- 九度oj 题目1020:最小长方形【ZJU2007考研机试题1】
- 九度oj 题目1022:游船出租 【ZJU2007考研机试题3】
- 九度oj 题目1023:EXCEL排序 【ZJU2007考研机试题4】
- 九度oj 题目1024:畅通工程 【ZJU2007考研机试题5】
- 通向架构师的道路(第十六天)IBM Websphere与IBM HttpServer的集成
- Android 程序获取、设置铃声、音量、静音、扬声器
- 通向架构师的道路(第十七天)IBM Websphere集群探秘-WASND
- tableview 小知识 实现聊天框
- 通向架构师的道路(第十八天)万能框架Spring(一)
- 九度oj 题目1468:Sharing 【ZJU2012考研机试题2】
- 九度题目1023:EXCEL排序
- sql面试常考题目_系列1
- 十六进制转八进制
- 通向架构师的道路(第十九天)使用maven构建Spring工程
- 通向架构师的道路(第二十天)万能框架spring(二)maven结合spring与ibatis
- redis.conf配置说明
- mfc中的ddx和ddv
- android JNI学习七