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

I want to win Miss Universe Nigeria like my mum — Dr Danielle Adewusi

Medical doctor and beauty pageant contestant Dr. Danielle Adewusi is making headlines across the nation as she embarks on an inspiring quest to win...

The Real Truth About Led Strip Lights Room Decor Before You Buy

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Made in Abyss: Mezameru Shinpi Anime Film Unveils Trailer, Cast, Theme Song

Anime fans around the globe have reason to celebrate as the highly anticipated film Made in Abyss: Mezameru Shinpi has officially revealed its stunning...

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!