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

Previous submission (verdict: Wrong answer on test 2):
#include<set>

#include<map>

#include<ctime>

#include<queue>

#include<stack>

#include<cmath>

#include<vector>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<iostream>

#include<algorithm>



#define int long long



using namespace std;



const int N = 1e6 + 100;

const int MOD = 998244353;

const int INF = 1e18 + 7;



int gi()

{

   int s=0,f=1;char ch=getchar();

   while(!(ch>='0'&&ch<='9')) f=(ch=='-'?-1:1),ch=getchar();

   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();

   return s*f;

}



int PRINT[333];

void print(int x)

{

    if(!x) 

    {

        putchar('0');

        return;

    }

    if(x<0) putchar('-'),x=-x;

    int ppp=0;

    while(x) PRINT[++ppp]=x%10,x/=10;

    for(int i=ppp;i>=1;--i) putchar(PRINT[i]+'0');

}



int T;

int n,m;

int A[N],B[N];

char ch[N];



signed main()

{

    T=gi();

    while(T--)

    {

        n=gi();

        int x=gi(),y=gi();

        if(n&1)

        {

            for(int i=1;i<n;++i) A[i]=i&1;

            A[n]=2;

        }

        else

        {

            for(int i=1;i<=n;++i) A[i]=i&1;

        }

        if(A[x]!=A[y])

        {

            for(int i=1;i<=n;++i) printf("%d ",A[i]);

            putchar('\n');

            continue;

        }

        if(n%2==0)

        {

            A[x]=2;

        }

        else

        {

            if(x==1||x==n-1) A[n]=A[x],A[x]=2;

            else A[x]=2;

        }

        for(int i=1;i<=n;++i) printf("%d ",A[i]);

        putchar('\n');

    }

}

Submission (verdict: Accepted):
#include<set>

#include<map>

#include<ctime>

#include<queue>

#include<stack>

#include<cmath>

#include<vector>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<iostream>

#include<algorithm>



#define int long long



using namespace std;



const int N = 1e6 + 100;

const int MOD = 998244353;

const int INF = 1e18 + 7;



int gi()

{

   int s=0,f=1;char ch=getchar();

   while(!(ch>='0'&&ch<='9')) f=(ch=='-'?-1:1),ch=getchar();

   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();

   return s*f;

}



int PRINT[333];

void print(int x)

{

    if(!x) 

    {

        putchar('0');

        return;

    }

    if(x<0) putchar('-'),x=-x;

    int ppp=0;

    while(x) PRINT[++ppp]=x%10,x/=10;

    for(int i=ppp;i>=1;--i) putchar(PRINT[i]+'0');

}



int T;

int n,m;

int A[N],B[N];

char ch[N];



signed main()

{

    T=gi();

    while(T--)

    {

        n=gi();

        int x=gi(),y=gi();

        if(n&1)

        {

            for(int i=1;i<n;++i) A[i]=i&1;

            A[n]=2;

        }

        else

        {

            for(int i=1;i<=n;++i) A[i]=i&1;

        }

        if(A[x]!=A[y])

        {

            for(int i=1;i<=n;++i) printf("%d ",A[i]);

            putchar('\n');

            continue;

        }

        if(n%2==0)

        {

            A[x]=2;

        }

        else

        {

            int t=0;

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

            {

                if(i==x)

                {

                    A[i]=2;

                }

                else A[i]=t&1,++t;

            }

        }

        for(int i=1;i<=n;++i) printf("%d ",A[i]);

        putchar('\n');

    }

}