思路:模拟移动即可,如果球落入洞中停止移动。注意:有可能第一个位置就是洞!!

AC代码

#include <cstdio>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <utility>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define eps 1e-10
#define inf 0x3f3f3f3f
#define PI pair<int, int>
typedef long long LL;
const int maxn = 1e6 + 5;
int hole[maxn], pos[maxn];
int main() {
	int n, m, k;
	while(scanf("%d%d%d", &n, &m, &k) == 3) {
		memset(hole, 0, sizeof(hole));
		memset(pos, 0, sizeof(pos));
		int h;
		for(int i = 0; i < m; ++i) {
			scanf("%d", &h);
			hole[h] = 1;
		}
		pos[1] = 1;
		int ans = 1;
		int x, y, flag = 0;
		if(hole[1]) flag = 1;
		for(int i = 0; i < k; ++i) {
			scanf("%d%d", &x, &y);
			if(flag) continue;
			if(pos[x]) {
				pos[x] = 0;
				pos[y] = 1;
				ans = y;
			}
			else if(pos[y]){
				pos[y] = 0;
				pos[x] = 1;
				ans = x;
			}
			if(hole[ans]) flag = 1;
		}
		printf("%d\n", ans);
	}
	return 0;
}

如有不当之处欢迎指出!

最新文章

  1. Linux基础介绍【第四篇】
  2. 安卓开发之ListAdapter(二)
  3. iOS系列 基础篇 01 构建HelloWorld,剖析并真机测试
  4. WebService 错误:无法加载协定为xxx的终结点配置部分,因为找到了该协定的多个终结点配置
  5. R语言缺失值信息处理
  6. sgu 101 无向图有双重边的欧拉路径
  7. jquery元素查找方法
  8. UNIX环境高级编程——网络基础概念
  9. 交换机Trunk端口配置
  10. datarow用linq查询
  11. Linux系统采用netstat命令查看DDOS攻击的方法
  12. web项目-easyui-datagrid使用汇总
  13. 自定义view 波浪效果
  14. MySQL InnoDB下关于MVCC的一个问题的分析
  15. [minecraft]mcCoder制作有感
  16. TestNg 9. 参数化测试-DataProvider参数化
  17. 王之泰201771010131《面向对象程序设计(java)》第七周学习总结
  18. Spark Graphx
  19. Alpha冲刺第10天
  20. Redis中取得所有Key、过期时间配置与获取、Key过期通知。

热门文章

  1. 自己模拟的一个简单的tomcat
  2. 各模拟器adb连接端口
  3. 20_Python字典总结
  4. Django的思维导图
  5. python中的线程
  6. Go笔记-继承
  7. BZOJ 3881: [Coci2015]Divljak [AC自动机 树链的并]
  8. BZOJ 1176: [Balkan2007]Mokia [CDQ分治]
  9. zzcms8.2#任意用户密码重置#del.php时间盲注#复现
  10. 撸一撸Spring Cloud Ribbon的原理