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;
}

#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;
}

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

How Under Desk Storage Is Quietly Changing the Game

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Has a woman ever mated with an ape?

Throughout history, urban legends, mythology, and speculative fiction have frequently explored the boundaries between humans and animals. One of the most persistent and sensationalized...

Why Home Office Lighting Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!