题目链接:​​http://codeforces.com/contest/796/problem/B​​​
题意:给你n个杯子标号为(1~n),有m个杯子有洞,有k次操作,每次操作交换编号为u和编号为v的杯子,如果这个杯子有洞,骨头就会掉下去,初始骨头在位置1,现在问你k此操作以后骨头在哪里
解析:直接模拟,骨头掉洞里了,就不再更新答案

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
using namespace std;
const int maxn = 1e6+100;
const int inf = 0x7ffffff;
const int mod = 1e9;
int vis[maxn];
int main(void)
{
int n,m,k;
scanf("%d %d %d",&n,&m,&k);
memset(vis,0,sizeof(vis));
for(int i=0;i<m;i++)
{
int x;
scanf("%d",&x);
vis[x] = -1;
}
int ans = 1;
if(vis[1]==-1);
else
vis[1] = 1;
while(k--)
{
int u,v;
scanf("%d %d",&u,&v);
if(ans==u && vis[u]!=-1)
{
if(vis[v]!=-1)
swap(vis[u],vis[v]);
ans = v;
}
else if(ans==v && vis[v]!=-1)
{
if(vis[u]!=-1)
swap(vis[v],vis[u]);
ans = u;
}
}
printf("%d\n",ans);
return 0;
}