Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 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--;



        vi ans(n,0);

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



        int i=(x+1)%n;

        while(1){

            // cout <<i <<" ";

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

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

                else ans[i]=0;

                break;

            }

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

            else ans[i]=1;

            i=(i+1)%n;

        }



        i=(y+1)%n;

        // cout <<"\n";

        while(1){

            // cout <<i <<" ";

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

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

                else ans[i]=1;

                break;

            }

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

            else ans[i]=0;

            i=(i+1)%n;

        }

        // cout <<"\n";



        out(ans);

        // cout <<"-----\n";

    }

    return 0;

}

Submission (verdict: Accepted):
#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;

}