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

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>

#include<algorithm>

#include <bits/stdc++.h>

#include<vector>

typedef long long int ll;

#define pb push_back

#define vi vector<int>

#define vii vector<pair<int,int>> 

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

#define rall(n) n.rbegin(), n.rend()

//#define mod 1000000007

#define mod 998244353

#define INF (1LL<<62)

#define N 200006

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> 

// #include <ext/pb_ds/tree_policy.hpp> 

// using namespace __gnu_pbds;   

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

// int dx[9] = {1,-1,0,0,-1,-1,1,1};

// int dy[9] = {0,0,1,-1,1,-1,-1,1};

// ll power(int pow, ll n, ll m)

// {

//   ll result = 1;

//   while(n)

//   {

//     if(n%pow==1)

//     {

//       result = (result * pow)%mode;

//     }

//     else pow = (pow * pow)

//   }

// }

//long long power(long long a, long long b, long long mode)

// {

//     long long result = 1;

//     while (b) {

//         if (b & 1)

//             result = (result * a) % mode;

//         a = (a * a) % mode;

//         b >>= 1;

//     }

//     return result;

// }

ll arr[200010], seg[400010];

ll fact[100];

void build(int index, int low, int high, int pos)

{

    if(low==high)

    {

        seg[index] = arr[low];

        return;

    }

    int mid = (low+high)/2;

    if(pos==1)pos = 2;

    else pos = 1;

    build(2*index+1,low,mid,pos);

    build(2*index+2,mid+1,high,pos);



    if(pos==2)

    {

        seg[index] = seg[2*index+1] ^ seg[2*index+2];

    }

    else

    {

        seg[index] = seg[2*index+1] | seg[2*index+2];



    }

}

void point_update(int index, int low, int high, int node, int value)

{

    if(low == high)

    {

        seg[index] = 1;

        //cout<<seg[low]<<" "<<low<<endl;

        return;

    }

    int mid = (low + high)>>1;

    if(node <= mid && node >= low)

    {

        point_update(2*index + 1, low, mid, node, value);

    }

    else

    {

        point_update(2*index+2, mid+1, high, node, value);

    }

    seg[index] = seg[2*index+1] + seg[2*index+2];

    //cout<<index<<" ==> "<<seg[index]<<endl;



}

ll power(int x,int n)

{

    ll ans = 1;

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

    {

        ans = ans * x;

    }

    return ans;

}

ll powerMod(ll a, ll b){

    if(b==0) return 1;



    if(b%2==0){

        ll x = powerMod(a, b/2);

        return (x*x)%mod;

    }

    else {

        ll x = powerMod(a, b/2);

        return ((x*x)%mod * a)%mod;

    }



    return 0;

}



ll inverseMod(ll a){

    return powerMod(a, mod-2);

}



ll nCrMod(ll n, ll r){

    if (r == 0)

        return 1;

    if (r > n)

        return 0;

    

    return (fact[n] * inverseMod((fact[r] * fact[n-r]) % mod)) % mod;

}

bool first_less(std::pair<int, int> lhs, int rhs) {

    return lhs.first < rhs;

}

bool comp(pair<int,int>a, pair<int,int>b)

{

    if(a.first==b.first)

    {

        return a.second>b.second;

    }

    return a.first<b.first;

}





void solve()

{



  int t = 1; cin>>t;

  

  //cout<<t<<endl;

  while(t--)

  {

    int n, x, y; cin>>n>>x>>y;

    map<pair<int,int>,int>mp;



    int arr[n+10];



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



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

    {

        mp[{i,i+1}] = 1;

    }

    mp[{1,n}] = 1;



    if(mp[{x,y}]==0)

    {

        //cout<<"yuy";

        arr[y] = 1;

        arr[x] = 2;

        int s = 0;



        for(int i = y-1; i>x; i--)

        {

            arr[i] = s;

            if(s==0)s = 1;

            else s = 0;

        }

        s = 0;

        for(int i = y+1; i!=x;i++)

        {

            arr[i] = s;

            if(s==0)s = 1;

            else s = 0;



            i = i % n;

        }

    }

    else

    {

        if(n%2==0)

        {

            int s = 0;

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

            {

                arr[i] = s;

                if(s==0) s= 1;

                else s = 0;

            }

        }

        else

        {

            int s = 0;

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

            {

                arr[i] = s;

                if(s==0) s= 1;

                else s = 0;

            }

            arr[n] = 2;

        }

    }



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

    {

        cout<<arr[i]<<" ";

    }

    cout<<endl;

    

  }





  

}

        

 

int main()

{

   #ifndef ONLINE_JUDGE 

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

    freopen("outputra.o", "w", stdout);  

   #endif

   std::ios_base::sync_with_stdio(0);

   cin.tie(0);

   cout.tie(0);

 

   solve();   

   return 0;

    

    

}



Submission (verdict: Wrong answer on test 1):
#include<iostream>

#include<algorithm>

#include <bits/stdc++.h>

#include<vector>

typedef long long int ll;

#define pb push_back

#define vi vector<int>

#define vii vector<pair<int,int>> 

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

#define rall(n) n.rbegin(), n.rend()

//#define mod 1000000007

#define mod 998244353

#define INF (1LL<<62)

#define N 200006

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> 

// #include <ext/pb_ds/tree_policy.hpp> 

// using namespace __gnu_pbds;   

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

// int dx[9] = {1,-1,0,0,-1,-1,1,1};

// int dy[9] = {0,0,1,-1,1,-1,-1,1};

// ll power(int pow, ll n, ll m)

// {

//   ll result = 1;

//   while(n)

//   {

//     if(n%pow==1)

//     {

//       result = (result * pow)%mode;

//     }

//     else pow = (pow * pow)

//   }

// }

//long long power(long long a, long long b, long long mode)

// {

//     long long result = 1;

//     while (b) {

//         if (b & 1)

//             result = (result * a) % mode;

//         a = (a * a) % mode;

//         b >>= 1;

//     }

//     return result;

// }

ll arr[200010], seg[400010];

ll fact[100];

void build(int index, int low, int high, int pos)

{

    if(low==high)

    {

        seg[index] = arr[low];

        return;

    }

    int mid = (low+high)/2;

    if(pos==1)pos = 2;

    else pos = 1;

    build(2*index+1,low,mid,pos);

    build(2*index+2,mid+1,high,pos);



    if(pos==2)

    {

        seg[index] = seg[2*index+1] ^ seg[2*index+2];

    }

    else

    {

        seg[index] = seg[2*index+1] | seg[2*index+2];



    }

}

void point_update(int index, int low, int high, int node, int value)

{

    if(low == high)

    {

        seg[index] = 1;

        //cout<<seg[low]<<" "<<low<<endl;

        return;

    }

    int mid = (low + high)>>1;

    if(node <= mid && node >= low)

    {

        point_update(2*index + 1, low, mid, node, value);

    }

    else

    {

        point_update(2*index+2, mid+1, high, node, value);

    }

    seg[index] = seg[2*index+1] + seg[2*index+2];

    //cout<<index<<" ==> "<<seg[index]<<endl;



}

ll power(int x,int n)

{

    ll ans = 1;

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

    {

        ans = ans * x;

    }

    return ans;

}

ll powerMod(ll a, ll b){

    if(b==0) return 1;



    if(b%2==0){

        ll x = powerMod(a, b/2);

        return (x*x)%mod;

    }

    else {

        ll x = powerMod(a, b/2);

        return ((x*x)%mod * a)%mod;

    }



    return 0;

}



ll inverseMod(ll a){

    return powerMod(a, mod-2);

}



ll nCrMod(ll n, ll r){

    if (r == 0)

        return 1;

    if (r > n)

        return 0;

    

    return (fact[n] * inverseMod((fact[r] * fact[n-r]) % mod)) % mod;

}

bool first_less(std::pair<int, int> lhs, int rhs) {

    return lhs.first < rhs;

}

bool comp(pair<int,int>a, pair<int,int>b)

{

    if(a.first==b.first)

    {

        return a.second>b.second;

    }

    return a.first<b.first;

}





void solve()

{



  int t = 1; cin>>t;

  

  //cout<<t<<endl;

  while(t--)

  {

    int n, x, y; cin>>n>>x>>y;

    map<pair<int,int>,int>mp;



    int arr[n+10];



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



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

    {

        mp[{i,i+1}] = 1;

    }

    mp[{1,n}] = 1;



    if(mp[{x,y}]==0)

    {

        //cout<<"yuy";

        arr[y] = 1;

        arr[x] = 2;

        int s = 0;



        for(int i = y-1; i>x; i--)

        {

            arr[i] = s;

            if(s==0)s = 1;

            else s = 0;

        }

        s = 0;

        for(int i = y+1; i!=x;i++)

        {

            if(i>n)arr[1] = s;

            else

            arr[i] = s;

            if(s==0)s = 1;

            else s = 0;



            i = i % n;

        }

    }

    else

    {

        if(n%2==0)

        {

            int s = 0;

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

            {

                arr[i] = s;

                if(s==0) s= 1;

                else s = 0;

            }

        }

        else

        {

            int s = 0;

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

            {

                arr[i] = s;

                if(s==0) s= 1;

                else s = 0;

            }

            arr[n] = 2;

        }

    }



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

    {

        cout<<arr[i]<<" ";

    }

    cout<<endl;

    

  }





  

}

        

 

int main()

{

   #ifndef ONLINE_JUDGE 

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

    freopen("outputra.o", "w", stdout);  

   #endif

   std::ios_base::sync_with_stdio(0);

   cin.tie(0);

   cout.tie(0);

 

   solve();   

   return 0;

    

    

}