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

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

using namespace std;

#define ll long long

#define lc(t) ll t; cin >> t;

#define f(i,a,n) for (ll i=a; i<n; i++)

#define sp cout << " ";

#define nl cout << "\n";

#define fmc(i,n,a) ll a[n]; for (ll i=0; i<n; i++) cin >> a[i]

#define fout(i,n,a) for (ll i=0; i<n; i++) cout << a[i] << " "

#define pb push_back

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

#define sz(x) (ll)x.size()

#define vi vector<int>

#define vll vector<ll>

#define F first

#define S second

#define endl "\n"

#define mod 1000000007

#define inf 1000000000000000000

#define pi 3.141592653589793238462643383279502884197169399

#define krish ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define ld long double

 

bool isprime (ll n)

{

    if (n<=1) return false;

    if(n==2 || n==3) return true;

    if(n%2==0 || n%3==0) return false;

    for (ll i=5; i<=sqrt(n); i+=6)  if (n%i==0 || n%(i+2)==0) return false;

    return true;

}



bool s(pair <string,ll> a, pair <string,ll> b)

{

    return a.second>b.second;

}

 

void fun()

{

    lc(n);

    lc(x);

    lc(y);

    x--, y--;

    if ( n%2==0 )

    {

        f(i,0,n)

        {

            if ( i==x && (x%2)==(y%2) ) cout << "2 ";

            else cout << (i+1)%2 << ' ';

        }

        cout << endl;

        return;

    }

    else

    {

        f(i,0,n)

        {

            if ( i==y && (x%2)==(y%2) )

            {

                cout << "2 ";

                if ( y==(n-2) )

                {

                    cout << "0 ";

                    break;

                }

            }

            else cout << (i+1)%2 << ' ';

        }

        cout << endl;

        return;

    }

    return;

}

 

int main()

{

    krish;

    lc(t);

    // ll t = 1;

    while (t--) fun();

    return 0;

}

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

using namespace std;

#define ll long long

#define lc(t) ll t; cin >> t;

#define f(i,a,n) for (ll i=a; i<n; i++)

#define sp cout << " ";

#define nl cout << "\n";

#define fmc(i,n,a) ll a[n]; for (ll i=0; i<n; i++) cin >> a[i]

#define fout(i,n,a) for (ll i=0; i<n; i++) cout << a[i] << " "

#define pb push_back

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

#define sz(x) (ll)x.size()

#define vi vector<int>

#define vll vector<ll>

#define F first

#define S second

#define endl "\n"

#define mod 1000000007

#define inf 1000000000000000000

#define pi 3.141592653589793238462643383279502884197169399

#define krish ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define ld long double

 

bool isprime (ll n)

{

    if (n<=1) return false;

    if(n==2 || n==3) return true;

    if(n%2==0 || n%3==0) return false;

    for (ll i=5; i<=sqrt(n); i+=6)  if (n%i==0 || n%(i+2)==0) return false;

    return true;

}



bool s(pair <string,ll> a, pair <string,ll> b)

{

    return a.second>b.second;

}

 

void fun()

{

    lc(n);

    lc(x);

    lc(y);

    x--, y--;

    if ( n%2==0 )

    {

        f(i,0,n)

        {

            if ( i==x && (x%2)==(y%2) ) cout << "2 ";

            else cout << (i+1)%2 << ' ';

        }

        cout << endl;

        return;

    }

    else

    {

        f(i,0,n-1)

        {

            if ( i==y && (x%2)==(y%2) )

            {

                cout << "2 ";

                if ( y==(n-2) )

                {

                    cout << "0\n";

                    return;

                }

            }

            else cout << (i+1)%2 << ' ';

        }

        cout << "2\n";

        return;

    }

    return;

}

 

int main()

{

    krish;

    lc(t);

    // ll t = 1;

    while (t--) fun();

    return 0;

}