Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <algorithm>

#include <bitset>

#include <cassert>

#include <cmath>

#include <iomanip>

#include <iostream>

#include <limits.h>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <string>

#include <vector>



#define  DBG(x         ) cerr<<#x<<" = "<<(x)<<endl;

#define DBG2(x, y      ) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<endl;

#define DBG3(x, y, z   ) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<endl;

#define DBG4(x, y, z, w) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<", "<<#w<<" = "<<(w)<<endl;

#define SEPA cerr<<" ============ "<<endl;



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

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



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

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

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

#define pb push_back

#define endl '\n'

#define fst first

#define snd second

#define pii pair<int, int>

#define pll pair<long long, long long>

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;



using namespace std;



void run_case(){

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

    x--, y--;

    vector<int> ans(n);

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

        ans[i] = (i % 2 == 1);

    

    if(n & 1) ans[0] = 2;

    

    auto mex = [&](int a, int b, int c = 1e5){

        int res = 0;

        for(int i = 0; i < 5; i++)

            if(i != a && i != b && i != c){

                res = i; 

                break;

            }

        return res;

    };

    ans[x] = mex(ans[((x - 1) + n) % n], ans[(x + 1) % n]);

    ans[y] = mex(ans[((y - 1) + n) % n], ans[(y + 1) % n], ans[x]);

    for(int x : ans) cout<<x<<' '; cout<<endl;

}



int main(){

    fast_io

    //freopen("input.in", "r", stdin);

    bool mtc = true;

    int tc = 1; if(mtc) cin>>tc;

    for(int i = 0; i < tc; i++) run_case();

    return 0;

}

Submission (verdict: Wrong answer on test 1):
#include <algorithm>

#include <bitset>

#include <cassert>

#include <cmath>

#include <iomanip>

#include <iostream>

#include <limits.h>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <string>

#include <vector>



#define  DBG(x         ) cerr<<#x<<" = "<<(x)<<endl;

#define DBG2(x, y      ) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<endl;

#define DBG3(x, y, z   ) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<endl;

#define DBG4(x, y, z, w) cerr<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<", "<<#w<<" = "<<(w)<<endl;

#define SEPA cerr<<" ============ "<<endl;



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

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



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

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

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

#define pb push_back

#define endl '\n'

#define fst first

#define snd second

#define pii pair<int, int>

#define pll pair<long long, long long>

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;



using namespace std;



void run_case(){

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

    x--, y--;

    vector<int> ans(n);

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

        ans[i] = (i % 2 == 1);

    

    //for(int x : ans) cout<<x<<' '; cout<<endl;

    

    auto mex = [&](int a, int b, int c = 1e5){

        int res = 0;

        for(int i = 0; i < 5; i++)

            if(i != a && i != b && i != c){

                res = i; 

                break;

            }

        return res;

    };

    ans[x] = mex(ans[((x - 1) + n) % n], ans[(x + 1) % n]);

    ans[y] = mex(ans[((y - 1) + n) % n], ans[(y + 1) % n], ans[x]);

    for(int x : ans) cout<<x<<' '; cout<<endl;

    if(x != 0)

        ans[0] = mex(ans.back(), ans[1]);

}



int main(){

    fast_io

    //freopen("input.in", "r", stdin);

    bool mtc = true;

    int tc = 1; if(mtc) cin>>tc;

    for(int i = 0; i < tc; i++) run_case();

    return 0;

}