Codeforces Round #408 (Div. 2) B. Find The Bone
来源:互联网 发布:剑三捏脸数据成男动漫 编辑:程序博客网 时间:2024/06/03 21:01
题目链接:Find The Bone
题意是给你n,m,k三个数,n代表有n个位置,m代表有m个分部在1到n的洞,k代表有k种操作,然后给你m个洞的位置,然后给你k对数,表示交换这两个位置的东西,然后有一个球,初始位置为1,问最后的时候这个球在哪个位置,如果某一个时刻这个球在洞里,就不能再动了。我的做法是把所有的洞存在一个set里面,然后每次操作之前判断一下球是不是在洞里,如果不在再看交换的两个位置有没有球当前所在的位置,在的话就交换一下,然后,具体看代码(当时有人没有考虑洞里包含1然后一开始就掉下去的情况,然后等了半天等到电脑没电就吃了一个hack,exm?幸好开的是小号)
#include <iostream>#include <algorithm>#include <stdio.h>#include <set>#include <vector>#include <map>using namespace std;typedef long long ll;ll n,m,k,ho[1000005],a,b;int main(){ ios::sync_with_stdio(false); while(cin>>n>>m>>k){ set<ll>s; s.clear(); for(int i = 0;i < m;i++) cin>>ho[i],s.insert(ho[i]); int bone = 1,flag = 0; while(k--){ cin>>a>>b; if(s.find(bone) != s.end()) flag = 1; else if(bone == a&&flag == 0) bone = b; else if(bone == b&&flag == 0) bone = a; if(flag == 1) continue; } cout<<bone<<endl; } return 0;}
0 0
- codeforces round#408(div.2) B. Find The Bone
- Codeforces Round #408 (Div. 2)-B. Find The Bone
- Codeforces Round #408 (Div. 2) B. Find The Bone
- Codeforces Round #408 (Div. 2) B.Find The Bone(模拟)
- Codeforces Round #408 B. Find The Bone
- Codeforces Round #408 (Div. 2) B. Find The Bone【模拟】水题~
- CodeForces 796B Find The Bone
- 【CodeForces 796B】Find The Bone
- 【Codeforces 796 B. Find The Bone】
- Find The Bone (Codeforces-796B)
- 【Codeforces Round #398 (Div. 2)】Codeforces 767B The Queue
- B. The Festive Evening(Codeforces Round #426 (Div. 2) B)
- B. Find The Bone
- Codeforces Round #258 (Div. 2) 2B Sort the Array
- Codeforces Round #202 (Div. 2) B.Color the Fence
- Codeforces Round #202 (Div. 2) B. Color the Fence
- Codeforces Round #258 (Div. 2/B)/Codeforces451B_Sort the Array
- Codeforces Round #258 (Div. 2) B. Sort the Array
- 线程通信,线程安全,volatile关键字
- caller_And_callee
- linux环境搭建(java+mysql+maven+tomcat+nginx)
- 【个人笔记重点,不作为参考】主题:web优化
- vs2010调用matlab2011下的.m文件
- Codeforces Round #408 (Div. 2) B. Find The Bone
- arduino软件安装
- HBase split操作介绍
- Python+Selenium中级篇之1-Python IDE工具-PyCharm的安装和简单使用
- ZigBee 3.0 《Base-Device-Behavior-Specification》--Initialization
- 安卓学习
- 天下没有免费的午餐啊
- truncate、delete与drop的区别
- JDK1.8源码逐字逐句带你理解LinkedHashMap底层