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

Solution 1 (runtime: 93 ms):
#include<bits/stdc++.h>

using namespace std;



typedef long long  ll;



// constants...

const double pi = acos(-1);

const int    mod = 1e9+7;

const int   MAX = 1e9+5;

const ll     inf = 2e18;

const int Mx=200005;





// defines...

#define MP             make_pair

#define PB             push_back

#define fi             first

#define se             second

#define sz(x)          (int)x.size()

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

#define yes            cout<<"YES"<<endl;

#define no             cout<<"NO"<<endl;





void fast() {

ios::sync_with_stdio(false);

cin.tie(NULL); cout.tie(NULL);

}



ll modpow(ll a,ll p) {ll ans=1;while(p){if(p%2)ans=(ans*a)%mod;a=(a*a)%mod;p/=2;} return ans;}

ll inverse_mod(ll n) {return modpow(n,mod-2);}

ll gcd(ll a,ll b) {

    if(b==0)

    return a;

    else

    gcd(b,a%b);

}

bool f(ll a,ll b) {

    return a>b;

}

ll max_sum_subarrays(ll ara[],ll n) {

    ll ans=0,sum=0;

    for(ll k=0;k<n;k++) {

        sum=max(ara[k],sum+ara[k]);

        ans=max(ans,sum);

    }

    return ans;

}

ll comb(ll m, ll n) {

    ll x=max(m-n,n),ans = 1,i=1;

    for(ll j=m;j>=x+1;j--) {

        ans*=j;

        ans/=i;

        i++;

    }

    return ans;

}



bool compare(const pair<int,int>& a,const pair<int,int>& b) {

    return a.fi>b.fi;

}



bool comparepairs(const pair<pair<int,int>,int>& a,const pair<pair<int,int>,int>& b) {

    return a.fi.se<b.fi.se; 

}



void JUI() {

    int n,a,b;

    cin>>n>>a>>b;

    vector<int>jui;

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

        // if(i==n-1 && i&1!=1) jui.PB(2);

        if(i&1) jui.PB(1);

        else jui.PB(0);

    }

    if(n&1) jui[n-1]=2;

    if(b==a+1 || (a==1 && b==n) || (a%2==0 && b%2==1) || (a%2==1 && b%2==0)) {

        for(auto &i : jui) {

            cout<<i<<" ";

        }

        cout<<"\n";

        return;

    }

    if(a%2==1){

        // if(n%2==0 && a!=1) jui[0]=2;

        jui[a-1]=2;

        if(n%2==1) {

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

                if(i%2==0) jui[i]=1;

                else jui[i]=0;

            }

        }

        else{

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

                if(i%2==0) jui[i]=0;

                else jui[i]=1;

            }

        }

    }

    else{

        jui[a-1]=2;

        if(n%2==0) {

            for(int i=0;i<a-1;i++) {

                if(i&1) jui[i]=0;

                else jui[i]=1;

            }

        }

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

            if(i&1) jui[i]=0;

            else jui[i]=1;

        }

    }

    for(auto &i : jui){

        cout<<i<<" ";

    }

    cout<<"\n";

    

}



int main() {

    int t; 

    cin>>t;

    while(t--) {

        JUI();

    }

    // JUI();

    // return 0;

}



Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>

using namespace std;

 

#define int long long

#define double long double

#define forn(i,a,n) for(int i = a; i < n; i++)

#define sz(x) ((int)x.size())

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

#define vin(v) for(auto&x:v)cin>>x;

#define vout(v) for(auto x: v)cout<<x<<" ";cout<<endl;

#define chp(x) if(enable_debug) cout << "Checkpoint: " << x << endl;

#define endl "\n" 

#define NitroSpear ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);



const bool enable_debug = true; 

const int MAXN = 2e5+7;

const int MOD = 998244353;

const int inf = 1e17;



void solve(){ 

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

    vector<int> a(n); 

    a[0] = 0;

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

        int cand = 0;

        if(i == y-1) while(a[x-1] == cand || a[i-1] == cand) cand++;

        else while(a[i-1] == cand) cand++;

        a[i] = cand;

    }

    // cout << "n: " << n << " x: " << x << " y: " << y << " sequence: ";

    vout(a);

    return;    

}



int32_t main() {

    NitroSpear      

    int T = 1;

    cin >> T; //comment if 1 case only

    while(T--){

        solve();

    }

    return 0;

}