Problem: 2049C - MEX Cycle
Language: c++17 

Code 1:
#include<cstdio>

#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<queue>

#include<array>

#include<stack>

#include<set>

#include<map>

#include<vector>

#include<ctime>

#include<bitset>

#include<random>

#include<tuple>

#define ull unsigned long long 

#define ll long long

#define max_ll 9223372036854775807

#define max_int 2147483647

#define elif else if

#define rep(i, l, r) for(register ll i = l; i <= r; ++i)

#define nep(i, r, l) for(register ll i = r; i >= l; --i)

#define YES puts("Yes");

#define NO puts("No");

using namespace std;

template<class T>inline void read(T &x)

{

    x=0;char c=getchar();bool f=0;

    while(!isdigit(c))f^=c=='-',c=getchar();

    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();

    if(f)x=-x;

}

template<class T>inline void print(T x)

{

    if(x<0)putchar('-'),x=-x;

    if(x>9)print(x/10);

    putchar('0'+x%10);

}

int t;

int n;

int x,y;

int ans[200005];

void sol(){

	read(n);read(x);read(y);

	ans[x]=0;

	ans[y]=1;

	int len=y-x-1;

	if(len%2==0){

		for(int i=x+1;i<y;++i){

			ans[i]=ans[i-1]^1;

		}

	}else{

		for(int i=x+1;i<y-1;++i){

			ans[i]=ans[i-1]^1;

		}

		ans[y-1]=2;

	}

	len=n-len-2;

	int k=1;

	if(len%2==0){

		for(int i=x-1;i>=1;i--){

			ans[i]=k;

			k^=1;

		}

		for(int i=n;i>y;i--){

			ans[i]=k;

			k^=1;

		}

	}else{

		for(int i=x-1;i>=1;i--){

			ans[i]=k;

			k^=1;

		}

		for(int i=n;i>y;i--){

			ans[i]=k;

			k^=1;

		}

		ans[y%n+1]=2;

	}

	for(int i=1;i<=n;++i)

		printf("%d ",ans[i]);

	puts("");

}

int main(){

	read(t);

	while(t--){

		sol();

	}

	return 0;

}

Code 2:
#include<cstdio>

#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<queue>

#include<array>

#include<stack>

#include<set>

#include<map>

#include<vector>

#include<ctime>

#include<bitset>

#include<random>

#include<tuple>

#define ull unsigned long long 

#define ll long long

#define max_ll 9223372036854775807

#define max_int 2147483647

#define elif else if

#define rep(i, l, r) for(register ll i = l; i <= r; ++i)

#define nep(i, r, l) for(register ll i = r; i >= l; --i)

#define YES puts("Yes");

#define NO puts("No");

using namespace std;

template<class T>inline void read(T &x)

{

    x=0;char c=getchar();bool f=0;

    while(!isdigit(c))f^=c=='-',c=getchar();

    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();

    if(f)x=-x;

}

template<class T>inline void print(T x)

{

    if(x<0)putchar('-'),x=-x;

    if(x>9)print(x/10);

    putchar('0'+x%10);

}

int t;

int n;

int x,y;

int ans[200005];

void sol(){

	read(n);read(x);read(y);

	ans[x]=0;

	ans[y]=1;

	int len=y-x-1;

	if(len%2==0){

		for(int i=x+1;i<y;++i){

			ans[i]=ans[i-1]^1;

		}

	}else{

		for(int i=x+1;i<y-1;++i){

			ans[i]=ans[i-1]^1;

		}

		ans[y-1]=2;

	}

	len=n-len-2;

	int k=1;

	if(len%2==0){

		for(int i=x-1;i>=1;i--){

			ans[i]=k;

			k^=1;

		}

		for(int i=n;i>y;i--){

			ans[i]=k;

			k^=1;

		}

	}else{

		for(int i=x-1;i>=1;i--){

			ans[i]=k;

			k^=1;

		}

		for(int i=n;i>y;i--){

			ans[i]=k;

			k^=1;

		}

		ans[y+1]=2;

	}

	for(int i=1;i<=n;++i)

		printf("%d ",ans[i]);

	puts("");

}

int main(){

	read(t);

	while(t--){

		sol();

	}

	return 0;

}

Answer: 1