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

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

using namespace std;

#define ll long long

#define od(n) (n & 1)

#define loop(k) for (ll i = 0; i < k; i++)

#define out(k) cout << k << endl

ll ceil(ll a, ll b) { return (a + b - 1) / b; }

ll expo(ll a, ll b, ll mod)

{

    ll res = 1;

    while (b > 0)

    {

        if (b & 1)

            res = (res * a) % mod;

        a = (a * a) % mod;

        b = b >> 1;

    }

    return res;

}

ll pow(ll a, ll b)

{

    ll res = 1;

    while (b > 0)

    {

        if (b & 1)

            res = (res * a);

        a = (a * a);

        b = b >> 1;

    }

    return res;

}

ll mo(ll a, ll b) { return (a >= 0) ? a % b : ((a % b) + b) % b; }

void printv(vector<ll> v)

{

    loop(v.size()) cout << v[i] << " ";

    cout << endl;

}

void primeFactor(ll x, map<ll, ll> &mp)

{

    for (ll j = 2; j * j <= x; j++)

    {

        while (x % j == 0)

        {

            mp[j]++;

            x /= j;

        }

    }

    if (x > 1)

        mp[x]++;

}



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    ll t = 1;

    cin >> t;

    ll mod = 1e9;

    while (t--)

    {

        ll n, x, y;

        cin >> n >> x >> y;

        vector<int> v(n, 0);

        if (n & 1)

        {

            for (int i = 1; i < n - 2; i++)

                v[i] = !v[i - 1];

            v[n - 2] = 2;

            v[n - 1] = 1;

            if (v[x - 1] == v[y - 1])

                reverse(v.begin(), v.end());

        }

        else

        {

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

                v[i] = !v[i - 1];

            if (v[x - 1] == v[y - 1])

                v[x - 1] = 2;

        }

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

            cout << v[i] << " ";

        cout << endl;

    }

    return 0;

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define od(n) (n & 1)

#define loop(k) for (ll i = 0; i < k; i++)

#define out(k) cout << k << endl

ll ceil(ll a, ll b) { return (a + b - 1) / b; }

ll expo(ll a, ll b, ll mod)

{

    ll res = 1;

    while (b > 0)

    {

        if (b & 1)

            res = (res * a) % mod;

        a = (a * a) % mod;

        b = b >> 1;

    }

    return res;

}

ll pow(ll a, ll b)

{

    ll res = 1;

    while (b > 0)

    {

        if (b & 1)

            res = (res * a);

        a = (a * a);

        b = b >> 1;

    }

    return res;

}

ll mo(ll a, ll b) { return (a >= 0) ? a % b : ((a % b) + b) % b; }

void printv(vector<ll> v)

{

    loop(v.size()) cout << v[i] << " ";

    cout << endl;

}

void primeFactor(ll x, map<ll, ll> &mp)

{

    for (ll j = 2; j * j <= x; j++)

    {

        while (x % j == 0)

        {

            mp[j]++;

            x /= j;

        }

    }

    if (x > 1)

        mp[x]++;

}



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    ll t = 1;

    cin >> t;

    ll mod = 1e9;

    while (t--)

    {

        ll n, x, y;

        cin >> n >> x >> y;

        vector<int> v(n, 0);

        if (n & 1)

        {

            for (int i = 1; i < n - 2; i++)

                v[i] = !v[i - 1];

            v[n - 2] = 2;

            v[n - 1] = 1;

            if (v[x - 1] == v[y - 1])

            {

                vector<int> tmp(n);

                ll d = (n - 1) - min(x, y);

                int k = 0;

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

                    tmp[k++] = v[i];

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

                    tmp[k++] = v[i];

                v = tmp;

            }

        }

        else

        {

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

                v[i] = !v[i - 1];

            if (v[x - 1] == v[y - 1])

                v[x - 1] = 2;

        }

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

            cout << v[i] << " ";

        cout << endl;

    }

    return 0;

}