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

Code 1:
#pragma comment(linker, "/STACK:40000000")

#define _CRT_SECURE_NO_WARNINGS

#include<set>

#include<map>

#include<unordered_map>

#include<iostream>

#include<queue>

#include<sstream>

#include<cstdlib>

#include<cstdio>

#include<vector>

#include<string>

#include<cstring>

#include<algorithm>

#include<cassert>

#include<ctime>

using namespace std;

typedef vector<int>VI; typedef vector<VI>VVI;

typedef vector<string>VS;

typedef pair<int, int>PII;

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

#define FORN(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define FOR1(i,n) for((i)=1;(i)<=(n);(i)++)

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

#define SI(a) ((int)(a).size())

#define CLR(a) memset(a,0,sizeof(a))

#define PB push_back

#define MP make_pair



int n, x, y;

int a[200005];



void Solve()

{

    int i;

    FOR(i, n) a[i] = i % 2;

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

    if ((x + 1) % n == y || (y + 1) % n == x) return;

    if (n % 2)

    {

        FOR(i, n) a[(x + i) % n] = i % 2;

        a[x] = 2;

    }

    else a[x] = 2;

}



void WriteAnswer()

{

    int i;

    FOR(i, n)

    {

        if (i) cout << " ";

        cout << a[i];

    }

    cout << endl;

}



void ReadInput()

{

    cin >> n >> x >> y;

    x--, y--;

}



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

#if !ONLINE_JUDGE

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

#endif

    int t;

    for (cin >> t; t > 0; t--)

    {

        ReadInput();

        Solve();

        WriteAnswer();

    }

    return 0;

}



Code 2:
#pragma comment(linker, "/STACK:40000000")

#define _CRT_SECURE_NO_WARNINGS

#include<set>

#include<map>

#include<unordered_map>

#include<iostream>

#include<queue>

#include<sstream>

#include<cstdlib>

#include<cstdio>

#include<vector>

#include<string>

#include<cstring>

#include<algorithm>

#include<cassert>

#include<ctime>

using namespace std;

typedef vector<int>VI; typedef vector<VI>VVI;

typedef vector<string>VS;

typedef pair<int, int>PII;

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

#define FORN(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define FOR1(i,n) for((i)=1;(i)<=(n);(i)++)

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

#define SI(a) ((int)(a).size())

#define CLR(a) memset(a,0,sizeof(a))

#define PB push_back

#define MP make_pair



int n, x, y;

int a[200005];



void Solve()

{

    int i, j;

    FOR(i, n) a[i] = i % 2;

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

    if ((x + 1) % n != y && (y + 1) % n != x && a[x] == a[y])

    {

        if (n % 2) FOR(i, n) a[(x + i) % n] = i % 2;

        a[x] = 2;

    }

    /*FOR(i, n)

    {

        set<int> b;

        for (j = -1; j <= 1; j++) b.insert(a[(n + i + j) % n]);

        if (i == x) b.insert(a[y]);

        else if (i == y) b.insert(a[x]);

        for (j = 0; ; j++) if (!b.count(j)) break;

        if (a[i] != j)

        {

            ;

        }

    }*/

}



void WriteAnswer()

{

    int i;

    FOR(i, n)

    {

        if (i) cout << " ";

        cout << a[i];

    }

    cout << endl;

}



void ReadInput()

{

    cin >> n >> x >> y;

    x--, y--;

}



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

#if !ONLINE_JUDGE

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

#endif

    int t;

    for (cin >> t; t > 0; t--)

    {

        ReadInput();

        Solve();

        WriteAnswer();

    }

    return 0;

}



Answer: 2