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

Code 1:
#pragma optimize GCC(2)

#pragma optimize GCC(3)

#pragma optimize GCC("Ofast")

#include <bits/stdc++.h>

#define endl '\n'

// #define int long long

#define lowbit(x) x & -x

using i64 = long long;

using u64 = unsigned long long;

using ld = long double;

const int maxn = 2e5 + 5;

const int inf = 0x7f7f7f7f;

const int mod = 1e9 + 7;



struct custom_hash 

{

	static uint64_t splitmix64(uint64_t x)

    {

		x ^= x << 13;

		x ^= x >> 7;

		x ^= x << 17;

		return x; 

	}

	size_t operator () (uint64_t x) const 

    {

		static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count(); // 时间戳

		return splitmix64(x + FIXED_RANDOM);

	}

};

void solve()

{

    int n = 0, x = 0, y = 0;

    std::cin >> n >> x >> y;

    if (n & 1)

    {

        if (abs(x - y) & 1)

        {

            std::cout << 2 << " ";

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

            {

                std::cout << (i % 2) << " ";

            }

            std::cout << endl;

            return;

        }

        else

        {

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

            {

                if (i == x)

                {

                    std::cout << 2 << " ";

                }

                else

                {

                    if(abs(x - i) & 1)

                    {

                        std::cout << 1 << " ";

                    }

                    else

                    {

                        std::cout << 0 << " ";

                    }

                }

            }

            std::cout << endl;

            return;

        }

    }

    else

    {

        if (abs(x - y) & 1)

        {

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

            {

                std::cout << (i + 1) % 2 << " ";

            }

            std::cout << endl;

            return;

        }

        else

        {

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

            {

                if (i == x)

                {

                    std::cout << 2 << " ";

                }

                else if (abs(x - i) & 1)

                {

                    std::cout << 1 << " ";

                }

                else

                {

                    std::cout << 0 << " ";

                }

            }

            std::cout << endl;

            return;

        }

    }

}



signed main()

{

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr); std::cout.tie(nullptr);

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

    int t = 1;

    std::cin >> t;

    while(t--)

    {

        solve();

    }

    return 0;

}

Code 2:
#pragma optimize GCC(2)

#pragma optimize GCC(3)

#pragma optimize GCC("Ofast")

#include <bits/stdc++.h>

#define endl '\n'

// #define int long long

#define lowbit(x) x & -x

using i64 = long long;

using u64 = unsigned long long;

using ld = long double;

const int maxn = 2e5 + 5;

const int inf = 0x7f7f7f7f;

const int mod = 1e9 + 7;



struct custom_hash 

{

	static uint64_t splitmix64(uint64_t x)

    {

		x ^= x << 13;

		x ^= x >> 7;

		x ^= x << 17;

		return x; 

	}

	size_t operator () (uint64_t x) const 

    {

		static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count(); // 时间戳

		return splitmix64(x + FIXED_RANDOM);

	}

};

void solve()

{

    int n = 0, x = 0, y = 0;

    std::cin >> n >> x >> y;

    if (n & 1)

    {

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

        {

            if (i == x)

            {

                std::cout << 2 << " ";

            }

            else if (i < x)

            {

                if ((x - i) & 1) std::cout << 0 << " ";

                if ((x - i) % 2 == 0) std::cout << 1 << " ";

            }

            else

            {

                if((i - x) & 1) std::cout << 1 << " ";

                if ((i - x) % 2 == 0) std::cout << 0 << " ";

            }

        }

        std::cout << endl;

        return;

    }

    else

    {

        if((abs(x - y) & 1) || (x == n && y == 1) || (x == 1 && y == n))

        {

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

            {

                std::cout << (i + 1) % 2 << " ";

            }

            std::cout << endl;

            return;

        }

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

        {

            if (i == x)

            {

                std::cout << 2 << " ";

            }

            else if (abs(i - x) & 1)

            {

                std::cout << 0 << " ";

            }

            else

            {

                std::cout << 1 << " ";

            }

        }

        std::cout << endl;

        return;

    }

}



signed main()

{

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr); std::cout.tie(nullptr);

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

    int t = 1;

    std::cin >> t;

    while(t--)

    {

        solve();

    }

    return 0;

}

Answer: 2