Codeforces Round #408 (Div. 2), problem: (B) Find The Bone Solution in C

#include <stdio.h>

#define N 1000000

int main() {
static int hole[N];
int n, m, k, i, j;

scanf(“%d%d%d”, &n, &m, &k);
for (j = 0; j < m; j++) {
scanf(“%d”, &i);
i–;
hole[i] = 1;
}
i = 0;
while (k– > 0) {
int u, v, tmp;

scanf(“%d%d”, &u, &v);
u–, v–;
if (u == i || v == i) {
if (u == i)
tmp = u, u = v, v = tmp;
if (!hole[i])
i = u;
}
}
printf(“%d\n”, i + 1);
return 0;
}

(Visited 88 times, 1 visits today)

About the Author:

Leave A Comment