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

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

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define ll long long

#define forl(i,a,b)  for(ll i=a;i<=b;i++)

#define forlr(i,a,b)  for(ll i=a;i>=b;i--)

#define pb push_back

#define popb pop_back

#define gcd(x,y) __gcd(x,y)

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

#define mp make_pair

#define srt(x,i,j) sort(x.begin()+i, x.begin()+j+1)

#define rev(x,i,j) reverse(x.begin()+i, x.begin()+j+1)

#define vec(v,n) vector<ll> v(n)

#define vecx(v,n,x) vector<ll> v(n,x)

#define M 1000000007

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;





//Important functions---------------

// 1. power function

long long binpow(long long a, long long b) {

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a;

        a = a * a;

        b >>= 1;

    }

    return res;

}

 

long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



vector<ll> findDivisors(ll n) {

    std::vector<ll> divisors;

    ll sqrtN = sqrt(n);

 

    for (ll i = 1; i <= sqrtN; ++i) {

        if (n % i == 0) {

            divisors.push_back(i);

            if (i != n / i) {

                divisors.push_back(n / i);

            }

        }

    }

    return divisors;

}



ll ceill(ll num, ll div){

    if(num%div==0){

        return num/div;

    }



    ll val=num/div;

    return val+1;

}



ll mex(set<ll> b){

    if(b.find(0)==b.end()) return 0;

    else if(b.find(1)==b.end()) return 1;

    else if(b.find(2)==b.end()) return 2;

    return 3;



}



int main() {

std::ios::sync_with_stdio(false);

std::cin.tie(nullptr);

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif

ll t;

cin >> t;

while (t--) {

    ll n,x,y;

    cin>>n>>x>>y;

    vec(a,n);

    if(n&1){

        forl(i,0,n-1){

            if(i==n-1){

                a[i]=2;

            }

            else if(i&1) a[i]=0;

            else a[i]=1;

        }

    }

    else{

        forl(i,0,n-1){

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

            else a[i]=1;

        }

    }



    x--;

    y--;

    

    set<ll> b;

    b.insert(a[(x-1+n)%n]);

    b.insert(a[(x+1)%n]);

    b.insert(a[y%n]);

    // for(auto it:b) cout<<it<<" ";

    // cout<<"\n";

    a[x]=mex(b);

    b.clear();

    b.insert(a[(y-1)%n]);

    b.insert(a[(y+1)%n]);

    b.insert(a[x%n]);

    a[y]=mex(b);

    

    forl(i,0,n-1) cout<<a[i]<<" ";

    cout<<"\n";

}

return 0;

}

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

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define ll long long

#define forl(i,a,b)  for(ll i=a;i<=b;i++)

#define forlr(i,a,b)  for(ll i=a;i>=b;i--)

#define pb push_back

#define popb pop_back

#define gcd(x,y) __gcd(x,y)

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

#define mp make_pair

#define srt(x,i,j) sort(x.begin()+i, x.begin()+j+1)

#define rev(x,i,j) reverse(x.begin()+i, x.begin()+j+1)

#define vec(v,n) vector<ll> v(n)

#define vecx(v,n,x) vector<ll> v(n,x)

#define M 1000000007

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;





//Important functions---------------

// 1. power function

long long binpow(long long a, long long b) {

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a;

        a = a * a;

        b >>= 1;

    }

    return res;

}

 

long long binpow(long long a, long long b, long long m) {

    a %= m;

    long long res = 1;

    while (b > 0) {

        if (b & 1)

            res = res * a % m;

        a = a * a % m;

        b >>= 1;

    }

    return res;

}



vector<ll> findDivisors(ll n) {

    std::vector<ll> divisors;

    ll sqrtN = sqrt(n);

 

    for (ll i = 1; i <= sqrtN; ++i) {

        if (n % i == 0) {

            divisors.push_back(i);

            if (i != n / i) {

                divisors.push_back(n / i);

            }

        }

    }

    return divisors;

}



ll ceill(ll num, ll div){

    if(num%div==0){

        return num/div;

    }



    ll val=num/div;

    return val+1;

}



ll mex(set<ll> b){

    if(b.find(0)==b.end()) return 0;

    else if(b.find(1)==b.end()) return 1;

    else if(b.find(2)==b.end()) return 2;

    return 3;



}



int main() {

std::ios::sync_with_stdio(false);

std::cin.tie(nullptr);

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif

ll t;

cin >> t;

while (t--) {

    ll n,x,y;

    cin>>n>>x>>y;

    vec(a,n);

    if(n&1){

        forl(i,0,n-1){

            if(i==n-1){

                a[i]=2;

            }

            else if(i&1) a[i]=0;

            else a[i]=1;

        }

    }

    else{

        forl(i,0,n-1){

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

            else a[i]=1;

        }

    }



    x--;

    y--;

    set<ll> s;

    forl(i,0,n-1){

        s.clear();

        if(i==x){

            

            s.insert(a[(x-1+n)%n]);

            s.insert(a[(x+1)%n]);

            s.insert(a[y%n]);

            a[x]=mex(s);

        }

        else if(i==y){

            s.insert(a[(y-1+n)%n]);

            s.insert(a[(y+1)%n]);

            s.insert(a[x%n]);

            a[y]=mex(s);

        }

        else{

            s.insert(a[(i-1+n)%n]);

            s.insert(a[(i+1)%n]);

            a[i]=mex(s);

        }

    }    

    

    forl(i,0,n-1) cout<<a[i]<<" ";

    cout<<"\n";

}

return 0;

}