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

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. test for python thread

    #!/usr/bin/python # -*- coding: UTF-8 -*- import thread import time # 为线程定义一个函数 def print_time(threa ...

  2. TPYBoard开发板搭建与阿里云服务发送数据

       今天给大家带来的是TPYBoard V202开发板的一次测试项目使用心得.而测试项目就是给服务端发送硬件底层数据,而数据有产品名称,WF模块MAC地址,温湿度数据.      什么是MicroP ...

  3. js 生成 UUID

    在项目中遇到要生成 UUID 的需求,第一反应就是有没有原生的生成方法,找了找,发现没有,只能自己建立算法 function. 下面是我用的算法 function uuid(len, radix) { ...

  4. jsp中 scope="application" 表示

    jsp中 <jsp:useBean id="countbean" scope="application" class="count.counte ...

  5. 学会用git真的很重要

    一.首先,作为一名开发人员,目前个人菜鸟一个,觉得有个仓库来管理好自己的项目是真的很重要,而目前个人认为在git上面管理自己的项目是真的很不错的推荐,接下来给大家介绍一下如何使用git上传.管理自己的 ...

  6. win10下端口被占用解决办法

    调试socket通信的时候,如果程序未正常结束,重新启动会报端口被占用的错误. 一 查找被占用的端口 解决办法如下:按win+R输入cmd打开控制台,输入 netstat -ano|findstr 8 ...

  7. bootstrap---treeview使用方法

    1.html部分: <div id="tree"></div> 2.css设置展开/收缩按钮图片: .tree_arrows_down:before{ co ...

  8. selenium打开chrome浏览器代码

    import os from selenium import webdriver chromedriver = "C:\Program Files (x86)\Google\Chrome\A ...

  9. vue2.0开发时导入组件时出错

    导入自定义组件时出现了如下错误 ERROR Failed to compile with 1 errors 12:35:41 This dependency was not found: * comp ...

  10. BZOJ 3731 3731: Gty的超级妹子树 [树上size分块 !]

    传送门 题意:一棵树,询问子树中权值大于k的节点个数,修改点权值,插入新点,断开边:强制在线 该死该死该死!!!!!! MD我想早睡觉你知不知道 该死该死沙比提 断开边只会影响一个块,重构这个块就行了 ...