Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

typedef long long ll;

template <class type1>

using ordered_multiset = tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>;

typedef __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;

#define pb push_back

#define pp pop_back

#define endl '\n' 

#define dbg(x) cerr << #x << " = " << x << endl

const int mod = 1e9 + 7;

const double e = 1e-6;



void solve() {

    ll n, x, y;

    cin >> n >> x >> y;

    vector<ll> a(n+1);

    if(y < x) swap(x, y);

    if((y-x)%2 || (n+y-x)%2) {

        for(ll i = 0; x+i < y; ++i){

            if(i%2) a[i+x] = 1;

            else a[i+x] = 0;

        }

        a[y] = 2;

        for(ll i = 0; (n+x-i) > y  ; i++){

            if((x-i)%2){

                if((n+x-i)%n == 0) a[n] = 1;

                else a[(n+x-i)%n] = 1;

            } 

            else{

                if((n+x-i)%n == 0) a[n] = 0;

                else a[(n+x-i)%n] = 0;

            }

        }

    }

    else{

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

            if(i%2){

                if((x+i)%n == 0) a[n] = 1;

                else a[(x+i)%n] = 1;

            }

            else{

                if((x+i)%n == 0) a[n] = 0;

                else a[(x+i)%n] = 0;

            }

        }

    }

    for(ll i = 1; i <= n; ++i) cout << a[i] << " ";

    cout << endl;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t; cin >> t; while(t--)

    solve();

}



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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

typedef long long ll;

template <class type1>

using ordered_multiset = tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>;

typedef __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;

#define pb push_back

#define pp pop_back

#define endl '\n' 

#define dbg(x) cerr << #x << " = " << x << endl

const int mod = 1e9 + 7;

const double e = 1e-6;



void solve() {

    ll n, x, y;

    cin >> n >> x >> y;

    vector<ll> a(n+1);

    if(y < x) swap(x, y);

    if((y-x)%2 || (n+y-x)%2) {

        for(ll i = 0; x+i < y; ++i){

            if(i%2) a[i+x] = 1;

            else a[i+x] = 0;

        }

        a[y] = 2;

        for(ll i = 0; (n+x-i) > y  ; i++){

            if(i%2){

                if((n+x-i)%n == 0) a[n] = 1;

                else a[(n+x-i)%n] = 1;

            } 

            else{

                if((n+x-i)%n == 0) a[n] = 0;

                else a[(n+x-i)%n] = 0;

            }

        }

        

    }

    else{

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

            if(i%2){

                if((x+i)%n == 0) a[n] = 1;

                else a[(x+i)%n] = 1;

            }

            else{

                if((x+i)%n == 0) a[n] = 0;

                else a[(x+i)%n] = 0;

            }

        }

    }

    for(ll i = 1; i <= n; ++i) cout << a[i] << " ";

    cout << endl;

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t; cin >> t; while(t--)

    solve();

}