-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindTheBone.cpp
More file actions
38 lines (29 loc) · 786 Bytes
/
FindTheBone.cpp
File metadata and controls
38 lines (29 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <cstdio>
bool isHole[1000001];
using namespace std;
int main() {
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
for(int i = 0; i < m; i++) {
int temp;
scanf("%d", &temp);
isHole[temp] = true;
}
int bonePosition = 1;
bool isDropped = false;
for(int i = 0; i < k; i++) {
int start, end;
scanf("%d %d", &start, &end);
if(isDropped) continue;
if(start == bonePosition) {
isDropped = isHole[end];
if(!isHole[start]) bonePosition = end;
} else if(end == bonePosition) {
isDropped = isHole[start];
if(!isHole[end]) bonePosition = start;
}
}
printf("%d\n", bonePosition);
return 0;
}