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

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

using namespace std;

#define ll long long int



void yes()

{

    cout << "YES" << endl;

}



void no()

{

    cout << "NO" << endl;

}



void read(vector<ll> &arr, int n)

{

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

    {

        cin >> arr[i];

    }

}



ll mex(vector<ll> arr, int n)

{

    ll x = 0;

    sort(arr.begin(), arr.end());

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

    {

        if (arr[i] < (x))

        {

            continue;

        }

        else if (arr[i] == x)

        {

            x++;

        }

        else

        {

            break;

        }

    }



    return x;

}



void read_vecOfPairs(vector<pair<ll, ll>> &arr, int n)

{

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

    {

        ll x, y;

        cin >> x >> y;

        arr[i].first = x;

        arr[i].second = y;

    }

}



void print_arr(vector<ll> &arr, int n)

{

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

    {

        cout << arr[i] << ' ';

    }

    cout << endl;



    return;

}



void print_2darr(vector<vector<ll>> &arr, int n, int m)

{

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

    {

        for (int j = 0; j < m; j++)

        {

            cout << arr[i][j] << ' ';

        }

        cout << endl;

    }



    return;

}



// takes O(nlogn)

vector<ll> frequencySort(vector<ll> &nums)

{

    unordered_map<ll, ll> freq;

    for (ll num : nums)

    {

        freq[num]++;

    }



    sort(nums.begin(), nums.end(), [&](ll a, ll b)

         {

        if (freq[a] == freq[b]) {

            return a > b;

        }

        return freq[a] < freq[b]; });



    return nums;

}



// currently set to min first and max second;

bool sortComparator(const pair<int, int> &a, const pair<int, int> &b)

{

    if (a.first == b.first)

    {

        return (a.second > b.second);

    }

    return (a.first < b.first);

}



// Kadane algo

ll maxSubarraySum(vector<ll> &arr)

{

    ll res = arr[0];

    ll maxEnding = arr[0];



    for (int i = 1; i < arr.size(); i++)

    {

        maxEnding = max(maxEnding + arr[i], arr[i]);

        res = max(res, maxEnding);

    }

    return res;

}



ll factorial(int n)

{

    if (n == 0 || n == 1)

        return 1;

    return (long long int)n * factorial(n - 1);

}

void solve()

{

    int n,x,y;

    cin>>n>>x>>y;



    vector<ll> ans(n,0);

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

        if(i%2){

            ans[i]=1;

        }

    }

    if(n%2){

        ans[n-1]=2;



        if((x+y)%2==0){

            //same parity

            if(x!=1 && x!=(n-1)){

                ans[x-1]=2;

            }

            else{

                ans[y-1]=2;

            }

        }

        print_arr(ans,n);

    }

    else{

        if((x+y)%2==0){

            ans[x-1]=2;

        }



        print_arr(ans,n);

    }

    return;

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

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

using namespace std;

#define ll long long int



void yes()

{

    cout << "YES" << endl;

}



void no()

{

    cout << "NO" << endl;

}



void read(vector<ll> &arr, int n)

{

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

    {

        cin >> arr[i];

    }

}



ll mex(vector<ll> arr, int n)

{

    ll x = 0;

    sort(arr.begin(), arr.end());

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

    {

        if (arr[i] < (x))

        {

            continue;

        }

        else if (arr[i] == x)

        {

            x++;

        }

        else

        {

            break;

        }

    }



    return x;

}



void read_vecOfPairs(vector<pair<ll, ll>> &arr, int n)

{

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

    {

        ll x, y;

        cin >> x >> y;

        arr[i].first = x;

        arr[i].second = y;

    }

}



void print_arr(vector<ll> &arr, int n)

{

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

    {

        cout << arr[i] << ' ';

    }

    cout << endl;



    return;

}



void print_2darr(vector<vector<ll>> &arr, int n, int m)

{

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

    {

        for (int j = 0; j < m; j++)

        {

            cout << arr[i][j] << ' ';

        }

        cout << endl;

    }



    return;

}



// takes O(nlogn)

vector<ll> frequencySort(vector<ll> &nums)

{

    unordered_map<ll, ll> freq;

    for (ll num : nums)

    {

        freq[num]++;

    }



    sort(nums.begin(), nums.end(), [&](ll a, ll b)

         {

        if (freq[a] == freq[b]) {

            return a > b;

        }

        return freq[a] < freq[b]; });



    return nums;

}



// currently set to min first and max second;

bool sortComparator(const pair<int, int> &a, const pair<int, int> &b)

{

    if (a.first == b.first)

    {

        return (a.second > b.second);

    }

    return (a.first < b.first);

}



// Kadane algo

ll maxSubarraySum(vector<ll> &arr)

{

    ll res = arr[0];

    ll maxEnding = arr[0];



    for (int i = 1; i < arr.size(); i++)

    {

        maxEnding = max(maxEnding + arr[i], arr[i]);

        res = max(res, maxEnding);

    }

    return res;

}



ll factorial(int n)

{

    if (n == 0 || n == 1)

        return 1;

    return (long long int)n * factorial(n - 1);

}

void solve()

{

    int n,x,y;

    cin>>n>>x>>y;



    vector<ll> ans(n,0);

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

        if(i%2){

            ans[i]=1;

        }

    }

    if(n%2){

        ans[n-1]=2;

        if(x==n || y==n){

            int a=1;

        }

        else{

            if((x+y)%2==0){



                if(x%2){

                    if(x==n-2 || y==n-2){

                        if(x==n-2){

                            ans[x-1]=2;

                            ans[x]=0;

                            ans[x+1]=1;

                    

                        }

                        else{

                            ans[y-1]=2;

                            ans[y]=0;

                            ans[y+1]=1;

                        }

                    }

                }else{

                     //same parity

                    if(x!=1 && x!=(n-1)){

                        ans[x-1]=2;

                    }

                    else{

                        ans[y-1]=2;

                    }

                }

               

            }

        }

        

        print_arr(ans,n);

    }

    else{

        if((x+y)%2==0){

            ans[x-1]=2;

        }



        print_arr(ans,n);

    }

    return;

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}