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

Previous submission (verdict: Wrong answer on test 1):
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")

#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")

//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

#define YES cout << "YES"<<endl;

#define NO cout << "NO"<<endl;

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

#define pb emplace_back

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());



int rnd(int a, int b) {

	return rng() % (b - a + 1) + a;

}



string to_string(string s) { return s; }

template <typename T> string to_string(T v) {

  bool first = true;

  string res = "[";

  for (const auto &x : v) {

    if (!first)

      res += ", ";

    first = false;

    res += to_string(x);

  }

  res += "]";

  return res;

}



void dbg_out() { cerr << endl; }

template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {

  cerr << ' ' << to_string(H);

  dbg_out(T...);

}



#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)



template<class T> inline void chkmin(T& x, T y) { if (y < x) x = y; }

template<class T> inline void chkmax(T& x, T y) { if (y > x) x = y; }



using i64 = long long;

using u64 = unsigned long long;

using u32 = unsigned;

typedef long long ll;



const i64 INF = 1e18;

const int oo = 1e9;

const int mod = 1e9 + 7;

const int MX = 200005;



void solve() {

	int n, x, y;

	cin >> n >> x >> y;

	x --;

	y --;

	vector<int> a(n);

	if (x + 1 == y  || x == 0 && y == n - 1) {

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

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

		}

	} else if ((y - x) % 2) {

		int flg = 0;

		a[x] = 1;

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

			a[i] = flg;

			flg ^= 1;

		}

	} else if ((n - (y - x)) % 2) {

		int flg = 0;

		a[x] = 1;

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

			a[i] = flg;

			flg ^= 1;

		}

	}

	else {

		a[x] = 1, a[y] = 2;

		int flg = 0;

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

			a[i] = flg;

			flg ^= 1;

		}

		flg = 0;

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

			a[i] = flg;

			flg ^= 1;

		}

	}

	for (auto v: a) {

		cout << v << ' ';

	}

	cout << endl;

}



int main() {

#ifndef ONLINE_JUDGE

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

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

#endif



	ios::sync_with_stdio(0);

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



	int Tc = 1;

	cin >> Tc;

	while (Tc --) {

		solve();

	}

	return 0;

}



Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")

#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")

//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

#define YES cout << "YES"<<endl;

#define NO cout << "NO"<<endl;

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

#define pb emplace_back

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());



int rnd(int a, int b) {

	return rng() % (b - a + 1) + a;

}



string to_string(string s) { return s; }

template <typename T> string to_string(T v) {

  bool first = true;

  string res = "[";

  for (const auto &x : v) {

    if (!first)

      res += ", ";

    first = false;

    res += to_string(x);

  }

  res += "]";

  return res;

}



void dbg_out() { cerr << endl; }

template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {

  cerr << ' ' << to_string(H);

  dbg_out(T...);

}



#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)



template<class T> inline void chkmin(T& x, T y) { if (y < x) x = y; }

template<class T> inline void chkmax(T& x, T y) { if (y > x) x = y; }



using i64 = long long;

using u64 = unsigned long long;

using u32 = unsigned;

typedef long long ll;



const i64 INF = 1e18;

const int oo = 1e9;

const int mod = 1e9 + 7;

const int MX = 200005;



void solve() {

	int n, x, y;

	cin >> n >> x >> y;

	x --;

	y --;

	vector<int> a(n);

	if (x + 1 == y  || x == 0 && y == n - 1) {

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

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

		}

	} else if ((y - x) % 2) {

		int flg = 0;

		a[x] = 1;

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

			a[i] = flg;

			if (i == (x - 1 + n) % n) {

				if (a[i]) {

					a[i] = 2;

				}

			}

			flg ^= 1;

				

		}

	} else if ((n - (y - x)) % 2) {

		int flg = 0;

		a[x] = 1;

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

			a[i] = flg;

			if (i == (x + 1) % n) {

				if (a[i]) {

					a[i] = 2;

				}

			}

			flg ^= 1;

		}

	}

	else {

		a[x] = 1, a[y] = 2;

		int flg = 0;

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

			a[i] = flg;

			flg ^= 1;

		}

		flg = 0;

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

			a[i] = flg;

			flg ^= 1;

		}

	}

	for (auto v: a) {

		cout << v << ' ';

	}

	cout << endl;

}



int main() {

#ifndef ONLINE_JUDGE

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

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

#endif



	ios::sync_with_stdio(0);

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



	int Tc = 1;

	cin >> Tc;

	while (Tc --) {

		solve();

	}

	return 0;

}