Problem: 2049C - MEX Cycle
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<bits/stdc++.h>

#include<unordered_map>

#include<bitset>

using namespace std;

using ll = long long;



const int N = 2e5 + 5;

const int M = 998244353;

const int mod = 1e9 + 7;





void solve()

{

    int n, x, y;

    cin >> n >> x >> y;

    x--; y--;

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

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

        if (n & 1) {

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

                if (i == n - 1) cout << 2;

                else cout << i % 2 << " ";

            }

        }

        else for (int i = 0; i < n; i++) cout << i % 2 << " ";

        cout << endl; return;

    }

    vector<int> res(n + 1);

    if (n & 1) {

        res[x] = 0; res[y] = 1;

        if (((y - x) & 1)) {

            int cnt = 1;

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

                res[i] = cnt % 2, cnt++;



            cnt = 0;

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

                if (i == (x - 1 + n) % n) res[i] = 2;

                else res[i] = cnt % 2, cnt++;

            }

        }

        else {

            int cnt = 1;

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

                if (i == y - 1) res[i] = 2;

                else res[i] = cnt % 2, cnt++;



            cnt = 0;

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

                res[i] = cnt % 2, cnt++;

        }

    }

    else {

        if (((y - x) & 1) == 0) {

            res[x] = 1; res[y] = 0;

            int cnt = 0;

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

                if (i == y - 1) res[i] = 2;

                else res[i] = cnt % 2, cnt++;

            }

            cnt = 1;

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

                if (i == (x - 1 + n) % n) res[i] = 2;

                else res[i] = cnt % 2, cnt++;

            }

        

        }

        else {

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

                res[i % n] = i % 2;

        }

    }

    

    for (int i = 0; i < n; i++) cout << res[i] << " ";

    cout << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    int t = 1; cin >> t;

    while (t--) solve();

    return 0;

}

Solution 2 (runtime: 93 ms):
# include<bits/stdc++.h>

using namespace std;

#define endl '\n'

#define ll long long

int t;

int n,x,y;

int a[200005];

int main() {

	//freopen("CSBN.inp","r",stdin);

	//freopen("CSBN.out","w",stdout);

	cin>>t;

	while (t--) {

        cin>>n>>x>>y;

        for (int i = 1;i<=n;i++) a[i] = -1;

        a[x] = 0;

        a[y] = 1;

        a[x-1? x-1:n] = 1;

        a[x==n? 1:x+1] = 1;

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

            if (j!=a[y-1? y-1:n] && j!=a[y==n? 1:y+1] && j!=a[x]) {

                a[y] = j;

                break;

            }

        }

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

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

                if (i==x)  {

                    if (j!=a[i-1? i-1:n] && j!=a[i==n? 1:i+1] && j!=a[y]) {

                        a[i] = j;

                        break;

                    }

                }

                else if (i==y) {

                    if (j!=a[i-1? i-1:n] && j!=a[i==n? 1:i+1] && j!=a[x]) {

                        a[i] = j;

                        break;

                    }

                }

                else {

                    if (j!=a[i-1? i-1:n] && j!=a[i==n? 1:i+1]) {

                        a[i] = j;

                        break;

                    }

                }

            }

        }

        for (int i =1;i<=n;i++) cout<<a[i]<< ' ';

        cout<<endl;

	}

	return 0;

}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



/*#include <iostream>

#include <chrono>



int main() {

    auto start = std::chrono::high_resolution_clock::now();



    // ?o?n m? c?n do th?i gian th?c thi

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

        // Gi? l?p m?t c?ng vi?c n?ng

    }



    auto end = std::chrono::high_resolution_clock::now();

    std::chrono::duration<double> elapsed = end - start;



    std::cout << "Thoi gian thuc thi: " << elapsed.count() << " gi?y\n";

    return 0;

}*/

/*

     /\__/\

 o  ( >.<  )

 \-->  ^  <--\   O

   /       \ o  /

  (_________)--/

   (")  (")



*/

// :33 Dung the Bacons



//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



/*#include <iostream>

#include <chrono>



int main() {

    auto start = std::chrono::high_resolution_clock::now();



    // ?o?n m? c?n do th?i gian th?c thi

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

        // Gi? l?p m?t c?ng vi?c n?ng

    }



    auto end = std::chrono::high_resolution_clock::now();

    std::chrono::duration<double> elapsed = end - start;



    std::cout << "Thoi gian thuc thi: " << elapsed.count() << " gi?y\n";

    return 0;

}*/

/*

     /\__/\

 o  ( >.<  )

 \-->  ^  <--\   O

   /       \ o  /

  (_________)--/

   (")  (")



*/

// :33 Dung the Bacons