Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

 

typedef long long ll;

typedef unsigned long long ull; 

typedef pair<int, int> pii;

typedef pair<double, double> pdd;

typedef pair<long long, long long> pll;

typedef vector<int> vi;

typedef vector<long long> vll;

typedef map<int, int> mii;

typedef vector<vector<int>> vvi;

typedef vector<vector<long long>> vvll;

#define f(i, a, b, j) for(int i = int(a); i < int(b); i = i + int(j))

#define M map

#define V vector

#define P pair

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

#define rall(a) a.rbegin(), a.rend() 

#define nl "\n"

#define pb push_back

#define mp make_pair

#define reset(a, b) memset(a, int(b), sizeof(a))

#define MOD1 (ll)1000000007

#define MOD2 (ll)998244353



ll mod = MOD1;

ll power(ll a,ll b){

    ll res = 1;

    while(b){

        if(b & 1){

            res *= a;

            res %= mod;

        }

        a *= a;

        a %= mod;

         b >>= 1;

    }

    return res;

}

ll inverse(ll a){

    return power(a,mod - 2);

}



void solve(){

    ll n, x, y;

    cin >> n >> x >> y;

    x--;

    y--;

    if(abs(x - y) == 1 or abs(x - y) == n-1){

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

            cout << (i % 2) << " ";

        }

        if(n % 2){

            cout << 2 << " ";

        }

        cout << nl;

        return;

    }

    if(n % 2){

        ll curr = 0;

        vll val(n);

        val[x] = 2;

        for(int i = (x + 1) % n; i != x;){

            val[i] = curr;

            curr = (1 - curr);

            i++;

            i %= n;

        }

        for(auto e : val){

            cout << e << " ";

        }

        cout << nl;

        return;

    }

    // n even

    vll val(n);

    val[x] = 1;

    val[(x + 1) % n] = 2;

    val[(x + n - 1) % n] = 2;

    ll curr = ((ll)abs(x - y) % 2);

    for(int i = (x + 2) % n; i != (x + n - 1) % n; ){

        val[i] = curr;

        curr = (1 - curr);

        i++;

        i %= n;

    }

    for(auto e : val){

        cout << e << " ";

    }

    cout << nl;

    return;

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

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

        solve();

    }

    return 0;

}

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

using namespace std;

 

typedef long long ll;

typedef unsigned long long ull; 

typedef pair<int, int> pii;

typedef pair<double, double> pdd;

typedef pair<long long, long long> pll;

typedef vector<int> vi;

typedef vector<long long> vll;

typedef map<int, int> mii;

typedef vector<vector<int>> vvi;

typedef vector<vector<long long>> vvll;

#define f(i, a, b, j) for(int i = int(a); i < int(b); i = i + int(j))

#define M map

#define V vector

#define P pair

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

#define rall(a) a.rbegin(), a.rend() 

#define nl "\n"

#define pb push_back

#define mp make_pair

#define reset(a, b) memset(a, int(b), sizeof(a))

#define MOD1 (ll)1000000007

#define MOD2 (ll)998244353



ll mod = MOD1;

ll power(ll a,ll b){

    ll res = 1;

    while(b){

        if(b & 1){

            res *= a;

            res %= mod;

        }

        a *= a;

        a %= mod;

         b >>= 1;

    }

    return res;

}

ll inverse(ll a){

    return power(a,mod - 2);

}



void solve(){

    ll n, x, y;

    cin >> n >> x >> y;

    x--;

    y--;

    if(abs(x - y) == 1 or abs(x - y) == n-1){

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

            cout << (i % 2) << " ";

        }

        if(n % 2){

            cout << 2 << " ";

        }

        cout << nl;

        return;

    }

    if(n % 2){

        ll curr = 0;

        vll val(n);

        val[x] = 2;

        for(int i = (x + 1) % n; i != x;){

            val[i] = curr;

            curr = (1 - curr);

            i++;

            i %= n;

        }

        for(auto e : val){

            cout << e << " ";

        }

        cout << nl;

        return;

    }

    // n even

    if(abs(x - y) % 2){

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

            cout << (i % 2) << " ";

        }

        cout << nl;

        return;

    }

    vll val(n);

    val[x] = 1;

    val[(x + 1) % n] = 2;

    val[(x + n - 1) % n] = 2;

    ll curr = 1;

    for(int i = (x + 2) % n; i != (x + n - 1) % n; ){

        val[i] = curr;

        curr = (1 - curr);

        i++;

        i %= n;

    }

    for(auto e : val){

        cout << e << " ";

    }

    cout << nl;

    return;

}

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t;

    cin >> t;

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

        solve();

    }

    return 0;

}