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

Code 1:
#include <bits/stdc++.h>

using namespace std;



typedef long long       ll;

typedef vector<int>     vi;

typedef vector<vi>      vvi;

typedef vector<ll>      vll;

typedef pair<int,int>   pii;

typedef pair<ll,ll>     pll;

typedef vector<pii>     vpii;



// #define rep(i,x,y)      for(int i=x; true; i=(i+1)%n)

#define rrep(i,x,y)     for(int i=x; i>=y; i--)

#define inp(arr)        for(auto &x: arr) cin >>x;

#define ninp(arr,n)     int n; cin >>n; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define kinp(arr,n,k)   int n,k; cin >>n >>k; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define out(arr)        for(auto &x: arr){ cout <<x <<' ';} cout <<endl; 

#define EB              emplace_back

#define F               first

#define S               second

#define all(p)          p.begin(),p.end()





int main(){

    int t; cin >>t;

    while(t--){

        int n,x,y; cin >>n >>x >>y;

        x--, y--;



        // if((x+1)%n == y || (y+1)%n == x){}



        vi ans(n,0);

        ans[x]=0, ans[y]=1;



        int i=x, op = 0;

        while(1){

            // cout <<i <<" ";

            if((y==0 && i==n-1) || i==y-1){

                if(op==0) ans[i] = op;

                else ans[i] = 2;

                break;

            }

            ans[i] = op;

            op = 1 - op;

            i=(i+1)%n;

        }



        i=y, op = 1;

        // cout <<"\n";

        while(1){

            // cout <<i <<" ";

            if((x==0 && i==n-1) || i==x-1){

                if(op==0) ans[i]=2;

                else ans[i]=1;

                break;

            }

            ans[i] = op;

            op = 1 - op;

            i=(i+1)%n;

        }

        // cout <<"\n";



        out(ans);

    }

    return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;



typedef long long       ll;

typedef vector<int>     vi;

typedef vector<vi>      vvi;

typedef vector<ll>      vll;

typedef pair<int,int>   pii;

typedef pair<ll,ll>     pll;

typedef vector<pii>     vpii;



#define rep(i,x,y)      for(int i=x; i<y; i++, i%=n)

#define rrep(i,x,y)     for(int i=x; i>=y; i--)

#define inp(arr)        for(auto &x: arr) cin >>x;

#define ninp(arr,n)     int n; cin >>n; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define kinp(arr,n,k)   int n,k; cin >>n >>k; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define out(arr)        for(auto &x: arr){ cout <<x <<' ';} cout <<endl; 

#define EB              emplace_back

#define F               first

#define S               second

#define all(p)          p.begin(),p.end()





int main(){

    int t; cin >>t;

    while(t--){

        int n,x,y; cin >>n >>x >>y;

        x--, y--;



        vi ans(n,0);

        ans[x]=0, ans[y]=1;



        rep(i,x+1,y){

            if(i==y-1){

                if(i%2 != x%2) ans[i]=2;

                else ans[i]=0;

                continue;

            }

            if(i%2 == x%2) ans[i]=0;

            else ans[i]=1;

        }



        rep(i,y+1,x){

            if(i==x-1){

                if(i%2 != y%2) ans[i]=2;

                else ans[i]=1;

                continue;

            }

            if(i%2 == y%2) ans[i]=1;

            else ans[i]=0;

        }



        out(ans);

    }

    return 0;

}

Answer: 1