Skip to content

Commit f566801

Browse files
authored
Create MAGICHF
Here is the accepted solution of September long challenge 2018 of MAGICHF
1 parent c7c8f41 commit f566801

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Codechef/MAGICHF

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
SEPTEMBER 2018 LONG CHALLENGE
2+
link to the problem
3+
4+
https://www.codechef.com/SEPT18B/problems/MAGICHF/
5+
6+
#include<stdio.h>
7+
int main()
8+
{
9+
int N,X,S,T,A,B;
10+
scanf("%d",&T);
11+
while(T--)
12+
{
13+
scanf("%d%d%d",&N,&X,&S);
14+
while(S--)
15+
{
16+
scanf("%d%d",&A,&B);
17+
if(X==A)
18+
{
19+
X=B;
20+
}
21+
else if(X==B)
22+
{
23+
X=A;
24+
}
25+
26+
}
27+
28+
printf("%d\n",X);
29+
}
30+
return 0;
31+
}
32+
33+
34+
35+
36+
37+
38+

0 commit comments

Comments
 (0)