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

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;
}

如有不当之处欢迎指出!

CodeForces - 796B 模拟的更多相关文章

  1. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  2. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  3. Codeforces 709B 模拟

    B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  4. 【codeforces 796B】Find The Bone

    [题目链接]:http://codeforces.com/contest/796/problem/B [题意] 一开始骨头在1号位置; 然后有m个洞,给出洞的下标; 然后有k个交换操作; 如果骨头到洞 ...

  5. CodeForces - 404A(模拟题)

    Valera and X Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  6. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  7. Codeforces 452D [模拟][贪心]

    题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...

  8. CodeForces - 864C-Bus-(模拟加油站问题)

    https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...

  9. Codeforces 709C 模拟

    C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...

随机推荐

  1. jinja2.exceptions.TemplateNotFound: home/index.html

    问题: 检查路由路径和模版渲染方式,其他文件路径都正确,可以返回字符串,就是无法返回定义的模版,为什么flask无法启找到这个模版? 那,问题原因在哪? 在flask中,目录有着严格的定义,模版目录必 ...

  2. python_如何统计序列中元素

    问题1: 随机数列[12,5,8,7,8,9,4,8,5,...] 中出现次数最高的3个元素,他们出现的次数 问题2: 对某英文文章的单词,进行词频统计,找出出现次数最搞得10个单词,他们出现的次数是 ...

  3. Windows核心编程&内核对象

    1. 一个进程在初始化时,系统将会他分配一个空的句柄表,这个句柄表仅供内核对象使用,不供用户对象和GDI对象使用.进程在首次 初始化时,该句柄表为空.句柄表是一个由数据结构组成的数组,包含一个内核对象 ...

  4. Windows核心编程&错误处理

    知识概要 (1) MAKELANGID Windows宏,用一个来主语言标识和从语言标识创建一个语言标识符 MAKELANGID(ushort usPrimaryLanguage, ushort us ...

  5. junit测试套件

    在实际项目中,随着项目进度的开展,单元测试类会越来越多,可是直到现在我们还只会一个一个的单独运行测试类,这在实际项目实践中肯定是不可行的.为了解决这个问题,JUnit 提供了一种批量运行测试类的方法, ...

  6. css3 box-shadow让我们实现图层阴影效果

    box-shadow box-shadow: h-shadow v-shadow blur spread color inset;box-shadow:2px 2px 3px rgba(50,50,5 ...

  7. java for循环增强(foreach)

    for循环增强,在此之前还不知道foreach有这样的功能,先鄙视一下自己,留给自己看: 功能: ***若List用foreach : [  for(Student stu : list)  ]这种形 ...

  8. 微信浏览器返回刷新,监听微信浏览器返回事件,网页防复制,移动端禁止图片长按和vivo手机点击img标签放大图片

    以下代码都经过iphone7,华为MT7 ,谷歌浏览器,微信开发者工具,PC端微信验证.如有bug,还请在评论区留言. demo链接:https://pan.baidu.com/s/1c35mbjM ...

  9. 【原创】前端开发人员如何制作微信小程序模板

    (我的博客网站中的原文:http://www.xiaoxianworld.com/archives/305,欢迎遇到的小伙伴常来瞅瞅,给点评论和建议,有错误和不足,也请指出.) 最近接触了一下微信小程 ...

  10. iOS-FMDB事务【批量更新数据】

    打开数据库(sqlite) ///打开数据库 + (BOOL)openDataBase{ _TYDatabase = [[FMDatabase alloc]initWithPath:[self dat ...