ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: c++17 

Code 1:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool compareByFirst(const pair<int, int>& a, const pair<int, int>& b) {

    return a.first < b.first;

}

int findMex(int a, int b, int c) {

    set<int> s = {a, b, c}; // Store unique numbers

    

    for (int i = 0; ; i++) { // Check from 0 upwards

        if (s.find(i) == s.end()) return i;

    }

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	

	vector<int>a(n);

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

		a[i]=1;

		}

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

		a[i]=0;

		}

	if(n%2==1){

		a[n-1]=2;

		}

	if((y-x)%2==0){

		if(n%2==1 && y-1==n-2){

			swap(a[n-1],a[n-2]);

			}

		else{

			a[y-1]=2;

			}

		}

	for(auto t:a){

		cout<<t<<" ";

		}

	cout<<endl;

	}



int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

		}

	}



Code 2:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool compareByFirst(const pair<int, int>& a, const pair<int, int>& b) {

    return a.first < b.first;

}



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	

	vector<int>a(n);

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

		a[i]=1;

		}

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

		a[i]=0;

		}

	if(n%2==1){

		a[n-1]=2;

		}

	if((y-x)%2==0){

		a[y-1]=2;

		}

	for(auto t:a){

		cout<<t<<" ";

		}

	cout<<endl;

	}



int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

		}

	}



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

Code 1:
#include <bits/stdc++.h>

using namespace std;

const int N=505;

int t,n,x,y;

void solve(){

	cin>>n>>x>>y;

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

	int a=y-x,b=x+n-y;

	if (a>b) swap(a,b);

	if (a==1){

		if (n%2==1){

			for (int i=1;i<=n-1;i++) cout<<i%2<<" ";

			cout<<2<<" ";

		}

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

		cout<<'\n';

		return;

	}

	if (a%2!=b%2){

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

			if (i==x){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

		cout<<'\n';

		return;

	}

	if (a%2==b%2){

		if (a%2==0){

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

				if (i==x){

					cout<<2<<" ";

					continue;

				}

				cout<<i%2<<" ";

			}	

		}

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

		cout<<'\n';

		return;

	}

}

int main(){

	cin>>t;

	while (t--) solve();

	return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;

const int N=505;

int t,n,x,y;

int cha(int a,int b){

	if (a>b) swap(a,b);

	return min(b-a,a+n-b);

}

void solve(){

	cin>>n>>x>>y;

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

	int a=y-x,b=x+n-y;

	if (a>b) swap(a,b);

	if (a==1){

		if (n%2==1){

			for (int i=1;i<=n-1;i++) cout<<i%2<<" ";

			cout<<2<<" ";

		}

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

		cout<<'\n';

		return;

	}

	if (a%2!=b%2){

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

			if (i==x){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

		cout<<'\n';

		return;

	}

	if (a%2==b%2){

		if (a%2==0){

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

				if (i==x){

					cout<<2<<" ";

					continue;

				}

				cout<<i%2<<" ";

			}	

		}

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

		cout<<'\n';

		return;

	}

}

int main(){

	cin>>t;

	while (t--) solve();

	return 0;

}

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

Code 1:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;







void solve() {

    int n, x, y;

    cin>>n>>x>>y;



    vector<vector<int>> adj(n+1);

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

        int a = i+1>n?1:i+1;

        adj[i].push_back(a);



        int b = i-1<1?5:i-1;

        adj[i].push_back(b);



        if(i==x) adj[i].push_back(y);

        else if(i == y) adj[i].push_back(x);



    }



    vector<int> visited(n+1, -1);



    queue<int> q;

    q.push(1);

    visited[1] = 0;



    bool m = false;

    while(!q.empty()){

        int node = q.front();

        q.pop();



        m = !m;

        for(auto nnode: adj[node]){

            if(visited[nnode] == -1) {

                visited[nnode] = m;

                q.push(nnode);

            }

            

        }

    }





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

        bool found2 = false;

        bool same = false;

        for(auto nnode: adj[i]){

            if(visited[i] == visited[nnode]) same = true;

            else if(visited[nnode] == 2) found2 = true;

        }



        if(!found2 and same) visited[i] = 2;



        cout<<visited[i]<<" ";

    }

    cout<<endl;

    return;

}



int main() {

    // Uncomment for local debugging

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

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



    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    

    return 0;

}



Code 2:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;







void solve() {

    int n, x, y;

    cin>>n>>x>>y;



    vector<vector<int>> adj(n+1);

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

        int a = i+1>n?1:i+1;

        adj[i].push_back(a);



        int b = i-1<1?5:i-1;

        adj[i].push_back(b);



        if(i==x) adj[i].push_back(y);

        else if(i == y) adj[i].push_back(x);



    }



    vector<int> visited(n+1, -1);



    queue<int> q;

    q.push(1);

    visited[1] = 0;



    bool m = false;

    while(!q.empty()){



        int t = q.size();



        m = !m;

        while(t--){

            int node = q.front();

            q.pop();



            

            for(auto nnode: adj[node]){

                if(visited[nnode] == -1) {

                    visited[nnode] = m;

                    q.push(nnode);

                }

                

            }

        }

    }





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

        bool found2 = false;

        bool same = false;

        for(auto nnode: adj[i]){

            if(visited[i] == visited[nnode]) same = true;

            else if(visited[nnode] == 2) found2 = true;

        }



        if(!found2 and same) visited[i] = 2;



        cout<<visited[i]<<" ";

    }

    cout<<endl;

    return;

}



int main() {

    // Uncomment for local debugging

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

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



    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    

    return 0;

}



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

Code 1:
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

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

            a[i] = value;

            value = (value + 1) % 2;

        }

        

        if (n % 2 == 1 || (y -  x) % 2 == 0) {

            a[x] = 2;

        }



        std::vector<int> result(n);

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

            result[i % n] = a[i];

        }



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

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

Code 2:
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

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

            if (i == y && (i - x) % 3 == 0) {

                value++;

                a[i - 1] = 0;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }



        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

            if (a[x + n - 2] == 2) {

                a[x + n - 2] = 0;

            }

        }



        std::vector<int> result(n);

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

            result[i % n] = a[i];

        }



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

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

Answer: 1
Problem: 2049C - MEX Cycle
Language: python

Code 1:
for _ in range(int(input())):

	n,x,y=map(int,input().split())

	t=[0]*n

	x=x-1

	y=y-1

	x1=min(x,y)

	x2=max(x,y)

	cluster1=x2-x1-1

	cluster2=n-(x2-x1-1)

	pos1=-1

	pos2=-1

	if cluster1%2==1 :

		pos1=(x2+x1)//2

	if cluster2%2==1:

		pos2=((x1+x2+n)//2)%n

	hattan=0

	for i in range(n):

		if i!=pos1 and i!=pos2:

			t[i]=str(hattan)

			hattan=(hattan+1)%2

		else:

			t[i]="2"

	print(" ".join(t))

Code 2:


for _ in range(int(input())):

	n,x,y=map(int,input().split())

	t=[0]*n

	x1=min(x,y)

	x2=max(x,y)

	cluster1=x2-x1-1

	cluster2=n-(x2-x1-1)

	pos1=-1

	pos2=-1

	if cluster1%2==1 :

		pos1=(x2+x1)//2

	if cluster2%2==1:

		pos2=((x1+x2+n)//2)%n

	hattan=0

	for i in range(n):

		if i!=pos1 and i!=pos2:

			t[i]=str(hattan)

			hattan=(hattan+1)%2

		else:

			t[i]="2"

	print(" ".join(t))

		

	



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

Code 1:
#include <bits/stdc++.h>

using namespace std;



void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    x--; y--; 



    vector<int> a(n, -1);  

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



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

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

    }

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

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

    }



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

        cout << a[i] << " \n"[i == n - 1];

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--) solve();



    return 0;

}



Code 2:
#include <bits/stdc++.h>

using namespace std;



void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    x--; y--; 



    vector<int> a(n);

    a[x] = 0;

    a[y] = 1;

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

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

        if ((i + 1) % n == y && a[i] == 1) {

            a[i] = 2;

        }

    }

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

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

        if ((i - 1 + n) % n == y && a[i] == 1) {

            a[i] = 2;

        }

    }

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

        cout << a[i] << " \n"[i == n - 1];

    }

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--) solve();



    return 0;

}



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

Code 1:
#include <bits/stdc++.h>



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

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

        int a[n];

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

        {

            a[i%n]=i%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[x-1]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}

Code 2:
#include <bits/stdc++.h>



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

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

        int a[n];

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

        {

            a[i]=i%2;

        }

        if(n%2==0 && x%2==y%2)

        {

            a[x-1]=2;

        }

        else if(x%2==y%2)

        {

            a[x-1]=2;a[0]=2;

        }

        else if(n%2)

        {

            a[0]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}

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

Code 1:
#include <bits/stdc++.h>

using namespace std;

const int N=505;

int t,n,x,y;

void solve(){

	cin>>n>>x>>y;

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

	int a=y-x,b=x+n-y;

	if (a>b) swap(a,b);

	if (a==1){

		if (n%2==1){

			for (int i=1;i<=n-1;i++) cout<<i%2<<" ";

			cout<<2<<" ";

		}

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

		cout<<'\n';

		return;

	}

	if (a%2!=b%2){

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

			if (i==x){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

		cout<<'\n';

		return;

	}

	if (a%2==b%2){

		if (a%2==0){

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

				if (i==x){

					cout<<2<<" ";

					continue;

				}

				cout<<i%2<<" ";

			}	

		}

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

		cout<<'\n';

		return;

	}

}

int main(){

	cin>>t;

	while (t--) solve();

	return 0;

}

Code 2:
#include <bits/stdc++.h>

using namespace std;

const int N=505;

int t,n,x,y;

int cha(int a,int b){

	if (a>b) swap(a,b);

	return min(b-a,a+n-b);

}

void solve(){

	cin>>n>>x>>y;

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

	int a=y-x,b=x+n-y;

	if (a>b) swap(a,b);

	if (a==1){

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

		cout<<'\n';

		return;

	}

	if (a%2==b%2){

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

			if (i==x||i==y){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

		cout<<'\n';

		return;

	}

	if (a%2!=b%2){

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

			if (i==x){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

		cout<<'\n';

	}

}

int main(){

	cin>>t;

	while (t--) solve();

	return 0;

}

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

Code 1:
 #include<bits/stdc++.h>

#define ll long long int

using namespace std;

int main(){

    ll t;

    cin>>t;

    while(t--){

        ll n,x,y;

        cin>>n>>x>>y;

        vector<ll>v(n,0);

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

            if(i%2!=0) v[i]=1;

        }

        if(n%2==0 || (y-x)%2==0) v[x]=2;

        for(int i=0;i<=n-1;i++) cout<<v[i]<<" ";

        cout<<endl;

    }

    return 0;

}

Code 2:
 #include<bits/stdc++.h>

#define ll long long int

using namespace std;

int main(){

    ll t;

    cin>>t;

    while(t--){

        ll n,x,y;

        cin>>n>>x>>y;

        vector<ll>v(n,0);

        --x;

        --y;

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

            v[(x+i)%n] = i%2;

        }   

        if(n%2 || (y-x) % 2==0) v[x]=2;

        for(int i=0;i<=n-1;i++) cout<<v[i]<<" ";

        cout<<endl;

    }

    return 0;

}

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

Code 1:
#include<bits/stdc++.h>



using namespace std;



#define ll long long

#define vi vector<int>

#define pii pair<int,int>

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

#define pb push_back

#define f first

#define s second



const ll MOD = 1e9+7;



ll gcd(ll a, ll b) {

    if (a == 0) return b;

    return gcd(b % a, a);

}





ll pow(ll x, ll n) {

    if (n == 0) return 1;

    if (n % 2 == 0) return pow((x * x) % MOD, n / 2);

    return (x * pow((x * x) % MOD, (n - 1) / 2) % MOD);

}



void solve() {

    int n,x,y;

    cin>>n>>x>>y;

    

    int p[n+2]={0};

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

        for(int i=1; i<=n-1; i++) p[i]=(i%2);

        if(n%2) p[n]=2;

    }

    else {

        // x --> y ==> (y-x-1)

        // both side even => 0 - 1 => 1 0 1 0

        // else => odd side => 1 0 1 1 0 10 0

        int curr = 1;

        p[x]=0;

        p[y]=2;

        for(int i=x+1; i<y; i++) p[i] = p[i-1]^1; // x+1 ->y

        for(int i=x-1; i>=1; i--) p[i] = p[i+1]^1; // 1 -> x-1

        for(int i=n; i>y; i--) p[i] = p[(i+1)%n ==0 ? n : (i+1)%n]^1;// y+1 -> n

        

        if((y-x -1 )%2 == 0 && (n-y+x-1)%2 == 0) p[y]=1;

    }

    for(int i=1; i<=n; i++) cout<<p[i]<<" ";

    cout<<"\n";

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    

    int t=1;

    cin>>t;



    for(int i=01;i<=t;i++) {

        // cout<<"Case #"<<i<<"\n";

        solve();

    }



    return 0;

}

Code 2:
#include<bits/stdc++.h>



using namespace std;



#define ll long long

#define vi vector<int>

#define pii pair<int,int>

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

#define pb push_back

#define f first

#define s second



const ll MOD = 1e9+7;



ll gcd(ll a, ll b) {

    if (a == 0) return b;

    return gcd(b % a, a);

}





ll pow(ll x, ll n) {

    if (n == 0) return 1;

    if (n % 2 == 0) return pow((x * x) % MOD, n / 2);

    return (x * pow((x * x) % MOD, (n - 1) / 2) % MOD);

}



void solve() {

    int n,x,y;

    cin>>n>>x>>y;

    

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

        int dem = 2 + n%2;

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

        cout<<"\n";

        return;

    }

    // x --> y ==> (y-x-1)

    // both side even => 0 - 1 => 1 0 1 0

    // else => odd side => 1 0 1 1 0 10 0

    int p[n+2]={0};

    int curr = 1;

    p[x]=0;

    p[y]=2;

    for(int i=x+1; i<y; i++) p[i] = p[i-1]^1; // x+1 ->y

    for(int i=x-1; i>=1; i--) p[i] = p[i+1]^1; // 1 -> x-1

    for(int i=n; i>y; i--) p[i] = p[(i+1)%n ==0 ? n : (i+1)%n]^1;// y+1 -> n

    

    if((y-x -1 )%2 == 0 && (n-y+x-1)%2 == 0) p[y]=1;

    for(int i=1; i<=n; i++) cout<<p[i]<<" ";

    cout<<"\n";

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    

    int t=1;

    cin>>t;



    for(int i=01;i<=t;i++) {

        // cout<<"Case #"<<i<<"\n";

        solve();

    }



    return 0;

}

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

Code 1:
#include <iostream>

#include <vector>

#include <string>

#include <sstream>

#include <fstream>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <map>

#include <bitset>

#include <numeric>

#include <set>

#include <queue>

#include <unordered_map>

#include <cassert>

#include <array>

#include <deque>

#include <functional>





using namespace std;

#define NDEBUG

#define endl "\n"

#define ff first

#define ss second

#define vi vector<int>

#define pii pair<int, int>

#define sz(x) (int)x.size()

//#define int long long

constexpr int MAX_N = 100'005;

constexpr int INF = 1E9;  





int32_t main() {

    // ifstream cin("MEXcycle.txt");

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t; cin>>t; 



    while(t--) {

        int n, x, y; 

        cin>>n>>x>>y; 

        --x, --y; 



        vector<int> ans(n); 

        

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

            ans[(x + i) % n] = i % 2;

        }

        if (n % 2 || (x - y) % 2 == 0) {

            ans[x] = 2;

        }

    

        for (auto& i : ans) cout<<i<<" ";

        cout<<endl; 

    }

}

Code 2:
#include <iostream>

#include <vector>

#include <string>

#include <sstream>

#include <fstream>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <map>

#include <bitset>

#include <numeric>

#include <set>

#include <queue>

#include <unordered_map>

#include <cassert>

#include <array>

#include <deque>

#include <functional>





using namespace std;

#define NDEBUG

#define endl "\n"

#define ff first

#define ss second

#define vi vector<int>

#define pii pair<int, int>

#define sz(x) (int)x.size()

//#define int long long

constexpr int MAX_N = 100'005;

constexpr int INF = 1E9;  





int32_t main() {

    // ifstream cin("MEXcycle.txt");

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t; cin>>t; 



    while(t--) {

        int n, x, y; 

        cin>>n>>x>>y; 



        vector<int> ans; 

        

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

            if (i % 2) ans.push_back(0);

            else ans.push_back(1);

        }

        if (n % 2 == 0 && (x - y) % 2 == 0) {

            ans[x - 1] = 2;

        }

        else if (n % 2) {

            ans[0] = 2;

        }

        for (auto& i : ans) cout<<i<<" ";

        cout<<endl; 

    }

}

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

Code 1:
#include <bits/stdc++.h>



const int N = 200100;



int n, x, y;

int a[N];



int calc(std::vector<int> element) {

    for (int mex = 0;; mex ++) {

        bool flag = 0;

        for (int x : element)

            if (x == mex) {

                flag = 1;

                break;

            }

        

        if (!flag)

            return mex;

    }

}



void work() {

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



    a[x] = a[y] = -1;



    int state = 1;

    for (int i = x + 1; i <= y - 1; i ++)

        a[i] = (state ^= 1);

    

    state = 1;

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

        a[i] = (state ^= 1);

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

        a[i] = (state ^= 1);

    

    a[x] = calc({a[x == 1 ? n : x - 1], a[x == n ? 1 : x + 1]});

    a[y] = calc({a[y == 1 ? n : y - 1], a[y == n ? 1 : y + 1], a[x]});



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

        std::cout << a[i] << ' ';

    std::cout << '\n';

}



int main() {

    std::ios::sync_with_stdio(0);

    std::cin.tie(0);



    int T;

    std::cin >> T;



    while (T --)

        work();

    

    return 0;

}



/*

 *  心中无女人

 *  比赛自然神

 *  模板第一页

 *  忘掉心上人

**/

Code 2:
#include <bits/stdc++.h>



const int N = 200100;



int n, x, y;

int a[N];



int calc(std::vector<int> element) {

    for (int mex = 0;; mex ++) {

        bool flag = 0;

        for (int x : element)

            if (x == mex) {

                flag = 1;

                break;

            }

        

        if (!flag)

            return mex;

    }

}



void work() {

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



    a[x] = a[y] = -1;

    

    int state = 0;



    for (int i = x + 1; i <= y - 1; i ++)

        a[i] = (state ^= 1);

    

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

        a[i] = (state ^= 1);

    

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

        a[i] = (state ^= 1);

    

    a[x] = calc({a[x == 1 ? n : x - 1], a[x == n ? 1 : x + 1]});

    a[y] = calc({a[y == 1 ? n : y - 1], a[y == n ? 1 : y + 1], a[x]});



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

        std::cout << a[i] << ' ';

    std::cout << '\n';

}



int main() {

    std::ios::sync_with_stdio(0);

    std::cin.tie(0);



    int T;

    std::cin >> T;



    while (T --)

        work();

    

    return 0;

}



/*

 *  心中无女人

 *  比赛自然神

 *  模板第一页

 *  忘掉心上人

**/

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

Code 1:
#include <bits/stdc++.h>



using namespace std;





void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    x--,y--;

    vector<int>a(n);

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

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

    }

    if(n%2 || (y-x)%2==0){

        a[x]=2;

    }

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

        cout<<a[i]<<" ";

    }

    cout<<"\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

Code 2:
#include <bits/stdc++.h>



using namespace std;



void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    vector<int>a(n+1);

    a[1]=0;

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

        a[i]=(a[i-1]+1)%3;

    }



    if(a[x]==a[y]){

        a[y]=3-a[x]-a[y-1];

    }

    int z=(y+1)%n;

    if(a[z]==a[y]||a[z]==a[z+1]){

        a[z]=3-a[y]-a[z+1];

    }

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

        cout<<a[i]<<" ";

    }

    cout<<"\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

Answer: 1