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

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

//#include <atcoder/all>

using namespace std;

//using namespace atcoder;

//using mint = modint998244353;

//long long型=int64_tという認識で大丈夫です。

#define ll long long

#define ull unsigned long long

#define vec vector

#define vi vector<int>

#define vll vector<ll>

#define pq priority_queue

#define pb push_back

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

#define ld long double



const ll INF = 1e9;

const ll inf = 9e18;



struct Edge {

    int to;

    ll cost;

};



struct SEdge {

    int to;

    pair<ll, ll> cost;

};



template<class T>

using spq = priority_queue<T, vec<T>, greater<T>>; 



const vector<int> di = {-1, 0, 1, 1, 0, -1}, dj = {0, 1, 1, 0, -1, -1};



template<class T>

bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}



template<class T>

bool chmax(T& a, T b) {

    if(a < b) {

        a = b;

        return true;

    }

    return false;

}



using S = ll;



S op(S a, S b) {return a + b;}

S e() {return 0;}



int main() {

    int t; cin >> t;

    rep(i, 0, t) {

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

        vi ans(n, 0);

        rep(j, 0, n) {

            ans[j] = j % 2;

        }

        if(n % 2 == 1) ans[n - 1] = 2;

        if(ans[x] == ans[y]) {

            ans[max(x, y)] = 2;

            if(y == n - 2 && ans[n - 1] == 2) {ans[n - 1] = 1;}

            if(y == n - 3 && ans[n - 1] == 2) {ans[n - 2] = 0; ans[n - 1] = 1;}

        }

        rep(j, 0, n) cout << ans[j] << " ";

        cout << endl;

    }

}



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

//#include <atcoder/all>

using namespace std;

//using namespace atcoder;

//using mint = modint998244353;

//long long型=int64_tという認識で大丈夫です。

#define ll long long

#define ull unsigned long long

#define vec vector

#define vi vector<int>

#define vll vector<ll>

#define pq priority_queue

#define pb push_back

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

#define ld long double



const ll INF = 1e9;

const ll inf = 9e18;



struct Edge {

    int to;

    ll cost;

};



struct SEdge {

    int to;

    pair<ll, ll> cost;

};



template<class T>

using spq = priority_queue<T, vec<T>, greater<T>>; 



const vector<int> di = {-1, 0, 1, 1, 0, -1}, dj = {0, 1, 1, 0, -1, -1};



template<class T>

bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}



template<class T>

bool chmax(T& a, T b) {

    if(a < b) {

        a = b;

        return true;

    }

    return false;

}



using S = ll;



S op(S a, S b) {return a + b;}

S e() {return 0;}



int main() {

    int t; cin >> t;

    rep(i, 0, t) {

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

        vi ans(n, 0);

        rep(j, 0, n) {

            ans[j] = j % 2;

        }

        if(n % 2 == 1) ans[n - 1] = 2;

        if(ans[x] == ans[y]) {

            ans[max(x, y)] = 2;

            if(y == n - 2 && ans[n - 1] == 2) {ans[n - 2] = 3;}

            if(y == n - 3 && ans[n - 1] == 2) {ans[n - 2] = 0; ans[n - 1] = 1;}

        }

        rep(j, 0, n) cout << ans[j] << " ";

        cout << endl;

    }

}



Answer: 1