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


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>

using namespace std;

#define int long long 

void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    int round=1;

    vector<int>v(n,5);

    if((x==1&&y==0)||(x==1&&y==n)||(x==n&&y==0)||(x==n&&y==1)) round--;

    if(!round){

        int i=0;

      for(;i<n/2;i++){

        cout<<0<<" "<<1<<" ";

      }

      if(i*2!=n) cout<<2;

      cout<<endl;

    }

    else{

        if(n==4){

            if(x==1){

                cout<<0<<" "<<1<<" "<<2<<" "<<1<<endl;

            }

            else {

                cout<<1<<" "<<0<<" "<<2<<" "<<1<<endl; 

            }

        }

        else {

            if(n%2==0){

                    v[x-1]=0;

                    v[y-1]=1;

                if((y-x)%2==0){

                    

                    if(y!=n) {

                        v[y]=2; 

                        v[y-2]=2;    

                    }

                    else {

                        v[0]=2; 

                        v[y-2]=2; 

                    }

                    

                }

                bool a=true;

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

                    if(v[i]==5) {

                        if(a) v[i]=1;

                        else v[i]=0;

                    }

                    a=!a;

                }

                 a=true;

                for(int i=x-2;i>=0;i--){

                    if(v[i]==5) {

                        if(a) v[i]=1;

                        else v[i]=0;

                    }

                    a=!a;

                }

            }

            else {

                    v[x-1]=0;

                    v[y-1]=1;

                    if((y-x)%2==0){   

                            v[y-2]=2;      

                    }

                    else {

                        if(y!=n){

                            v[y]=2;

                        }

                        else {

                            v[0]=2;

                        }

                    }

                    bool a=true;

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

                        if(v[i]==5) {

                            if(a) v[i]=1;

                            else v[i]=0;

                        }

                        a=!a;

                    }

                    a=false;

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

                        if(v[i]==5) {

                            if(a) v[i]=1;

                            else v[i]=0;

                        }

                        a=!a;

                    }

                     a=true;

                    for(int i=x-2;i>=0;i--){

                        if(v[i]==5) {

                            if(a) v[i]=1;

                            else v[i]=0;

                        }

                        a=!a;

                    }  

                    

            }

             for(int i=0;i<n;i++){

            cout<<v[i]<<" ";

        }

        cout<<endl;

        }

       

    }

    



}

int32_t main(){

    int t=1;

    cin>>t;

    while (t--) solve();



}