ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 7):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

int datas[MAX];
int temp[MAX];
int choiced[MAX][MAX];
int n;
vector<pair<int,int>> ans;

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>datas[i];
        temp[i]=datas[i];
    }
    for(int i=1;i<=n;i++)
    {
        int now_pos=-1;
        for(int j=i;j<=n;j++)
        {
            if(temp[j]==i)
            {
                now_pos=j;
                break;
            }
        }
        int to_pos=i;
        for(int j=now_pos;j>to_pos;j--)
        {
            ans.push_back({temp[j-1],temp[j]});
            choiced[temp[j-1]][temp[j]]=1;
            swap(temp[j-1],temp[j]);
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=1;i<=n;i++)
    {
        vector<pair<int,int>> temp_ans;
        for(int j=i+1;j<=n;j++)
        {
            if(choiced[datas[j]][datas[i]]==1||choiced[datas[i]][datas[j]]==1)
            {
                break;
            }
            else
            {
                temp_ans.push_back({datas[j],datas[i]});
            }
        }
        for(int j=0;j<temp_ans.size();j++)
        {
            ans.push_back(temp_ans[j]);
        }
        for(int j=temp_ans.size()-1;j>=0;j--)
        {
            ans.push_back({temp_ans[j].second,temp_ans[j].first});
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
    {
        cout<<x.first<<' '<<x.second<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}


Submission (verdict: Wrong answer on test 1):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

int datas[MAX];
int temp[MAX];
int choiced[MAX];
int n;
vector<pair<int,int>> ans;

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        choiced[x]=1;
        for(int i=x;i<=n;i++)
        {
            if(choiced[i]==0)
            {
                ans.push_back({x,i});
            }
        }
        for(int i=n;i>=1;i--)
        {
            if(choiced[i]==0)
            {
                ans.push_back({i,x});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto [x,y]:ans)
    {
        cout<<x<<' '<<y<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

//int datas[MAX];
int choiced[MAX][MAX];
int vis[MAX];
map<int,int> mymap;
int n;
vector<pair<int,int>> ans;

void dfs(int from,int pos)
{
    if(vis[mymap[pos]]==1)
    {
        return ;
    }
    int nexts=mymap[pos];
    ans.push_back({nexts,from});
    choiced[nexts][from]=1;
    vis[nexts]=1;
    dfs(from,nexts);
}

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        mymap[i]=x;
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0&&mymap[i]!=i)
        {
            vis[i]=1;
            dfs(i,i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(choiced[i][j]==0&&choiced[j][i]==0)
            {
                ans.push_back({i,j});
                ans.push_back({j,i});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
    {
        cout<<x.first<<' '<<x.second<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}


Submission (verdict: Wrong answer on test 4):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

//int datas[MAX];
int choiced[MAX][MAX];
int vis[MAX];
map<int,int> mymap;
int n;
vector<pair<int,int>> ans;

void dfs(int from,int pos)
{
    if(vis[mymap[pos]]==1)
    {
        return ;
    }
    int nexts=mymap[pos];
    ans.push_back({nexts,from});
    choiced[nexts][from]=1;
    vis[nexts]=1;
    dfs(from,nexts);
}

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        mymap[i]=x;
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0&&mymap[i]!=i)
        {
            vis[i]=1;
            dfs(i,i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(choiced[i][j]==0&&choiced[j][i]==0)
            {
                ans.push_back({j,i});
                ans.push_back({i,j});

            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
    {
        cout<<x.first<<' '<<x.second<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

//int datas[MAX];
int choiced[MAX][MAX];
int vis[MAX];
map<int,int> mymap;
int n;
vector<pair<int,int>> ans;

void dfs(int from,int pos)
{
    if(vis[mymap[pos]]==1)
    {
        return ;
    }
    int nexts=mymap[pos];
    ans.push_back({nexts,from});
    choiced[nexts][from]=1;
    vis[nexts]=1;
    dfs(from,nexts);
}

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        mymap[i]=x;
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0&&mymap[i]!=i)
        {
            vis[i]=1;
            dfs(i,i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(choiced[i][j]==0&&choiced[j][i]==0)
            {
                ans.push_back({i,j});
                ans.push_back({j,i});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
    {
        cout<<x.first<<' '<<x.second<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

//int datas[MAX];
int choiced[MAX][MAX];
int vis[MAX];
map<int,int> mymap;
int n;
vector<pair<int,int>> ans;

void dfs(int from,int pos)
{
    if(vis[mymap[pos]]==1)
    {
        return ;
    }
    int nexts=mymap[pos];
    ans.push_back({nexts,from});
    choiced[nexts][from]=1;
    vis[nexts]=1;
    dfs(from,nexts);
}

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        mymap[i]=x;
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0&&mymap[i]!=i)
        {
            vis[i]=1;
            dfs(i,i);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(choiced[i][j]==0&&choiced[j][i]==0)
            {
                ans.push_back({j,i});
                ans.push_back({i,j});

            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
    {
        cout<<x.first<<' '<<x.second<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}


Submission (verdict: Wrong answer on test 7):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

int datas[MAX];
int temp[MAX];
int choiced[MAX][MAX];
int n;
vector<pair<int,int>> ans;

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>datas[i];
        temp[i]=datas[i];
    }
    for(int i=1;i<=n;i++)
    {
        int now_pos=-1;
        for(int j=i;j<=n;j++)
        {
            if(temp[j]==i)
            {
                now_pos=j;
                break;
            }
        }
        int to_pos=i;
        for(int j=now_pos;j>to_pos;j--)
        {
            ans.push_back({temp[j-1],temp[j]});
            choiced[temp[j-1]][temp[j]]=1;
            swap(temp[j-1],temp[j]);
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=1;i<=n;i++)
    {
        vector<pair<int,int>> temp_ans;
        for(int j=i+1;j<=n;j++)
        {
            if(choiced[datas[j]][datas[i]]==1||choiced[datas[i]][datas[j]]==1)
            {
                break;
            }
            else
            {
                temp_ans.push_back({datas[j],datas[i]});
            }
        }
        for(int j=0;j<temp_ans.size();j++)
        {
            ans.push_back(temp_ans[j]);
        }
        for(int j=temp_ans.size()-1;j>=0;j--)
        {
            ans.push_back({temp_ans[j].second,temp_ans[j].first});
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
    {
        cout<<x.first<<' '<<x.second<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=505;

char s[N];int n;

void work(){

    cin>>n;

    cin>>(s+1);

    int fl=0;int cs=0,cp=0;

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

        if(s[i]=='p')fl++,cp++;

        if(s[i]=='s'){

            if(fl==1)fl++;

            cs++;

        }

    }

    if(fl==2){

        cout<<"NO"<<endl;

        return;

    }

    if(cs==0||cp==0||(cp==1&&s[n]=='p')||(cs==1&&s[1]=='s')){

        cout<<"YES"<<endl;

    }else cout<<"NO"<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=505;

char s[N];int n;

void work(){

    cin>>n;

    cin>>(s+1);

    int fl=0;int cs=0,cp=0;

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

        if(s[i]=='p')fl++,cp++;

        if(s[i]=='s'){if(fl==1)fl++;cs++;}

    }

    if(fl==2){

        cout<<"NO"<<endl;

        return;

    }

    if(cs==0||cp==0||(cp==1&&s[n]=='p')||(cs==1&&s[1]=='s'))

        cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=505;

char s[N];int n;

void work(){

    cin>>n;

    cin>>(s+1);

    int fl=0;int cs=0,cp=0;

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

        if(s[i]=='p')fl++,cp++;

        if(s[i]=='s'){if(fl==1)fl++;cs++;}

    }

    if(fl==2){

        cout<<"NO"<<endl;

        return;

    }

    if(cs==0||cp==0||(cp==1&&s[n]=='p')||(cs==1&&s[1]=='s'))

        cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=505;

char s[N];int n;

void work(){

    cin>>n;

    cin>>(s+1);

    int fl=0;int cs=0,cp=0;

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

        if(s[i]=='p'){if(fl==0);cp++;}

        if(s[i]=='s'){if(fl==1)fl++;cs++;}

    }

    if(fl==2){

        cout<<"NO"<<endl;

        return;

    }

    if(cs==0||cp==0||(cp==1&&s[n]=='p')||(cs==1&&s[1]=='s'))

        cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=505;

char s[N];int n;

void work(){

    cin>>n;

    cin>>(s+1);

    int fl=0;int cs=0,cp=0;

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

        if(s[i]=='p')fl++,cp++;

        if(s[i]=='s'){

            if(fl==1)fl++;

            cs++;

        }

    }

    if(fl==2){

        cout<<"NO"<<endl;

        return;

    }

    if(cs==0||cp==0||(cp==1&&s[n]=='p')||(cs==1&&s[1]=='s')){

        cout<<"YES"<<endl;

    }else cout<<"NO"<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=2e5+5;

int a[N],n,x,y;

void work(){

    cin>>n>>x>>y;

    if(n&1){

        a[x]=2;

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

            x++;if(x==n+1)x=1;

            a[x]=(i&1);

        }

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

        cout<<endl;

        return;

    }

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

        a[i]=1,a[i+1]=0;

    if(a[x]==a[y]||x+1==y||(y+1==x)||(x==1&&y==n)||(x==n&&y==1)){

        if(a[x]==a[y])a[x]=2;

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

        cout<<endl;

    }else{

        a[x]=2;int xx=x;

        int fl=0;

        while(1){

            x++;if(x==n+1)x=1;

            if(x==y)break;

            if(fl==0)a[x]=0;

            if(fl==1)a[x]=2;

            if(fl>=2)a[x]=(fl-1)&1;

            fl++;

        }

        fl=0;x=xx;

        while(1){

            x--;if(x==0)x=n;

            if(x==y)break;

            if(fl==0)a[x]=0;

            if(fl==1)a[x]=2;

            if(fl>=2)a[x]=(fl-1)&1;

            fl++;

        }

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

        cout<<endl;

    }

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=2e5+5;

int a[N],n,x,y;

void work(){

    cin>>n>>x>>y;

    if(n&1){

        a[x]=2;

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

            x++;if(x==n+1)x=1;

            a[x]=(i&1);

        }

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

        cout<<endl;

        return;

    }

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

        a[i]=1,a[i+1]=0;

    if(a[x]==a[y]||x+1==y||(y+1==x)||(x==1&&y==n)||(x==n&&y==1)){

        if(a[x]==a[y])a[x]=2;

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

        cout<<endl;

    }else{

        a[x]=2;int xx=x;

        int fl=0;

        while(1){

            x++;if(x==n+1)x=1;

            if(x==y)break;

            if(fl==0)a[x]=0;

            if(fl==1)a[x]=2;

            if(fl>=2)a[x]=(fl-1)&1;

            fl++;

        }

        fl=0;x=xx;

        while(1){

            x--;if(x==0)x=n;

            if(x==y)break;

            a[x]=(fl-1)&1;

            fl++;

        }

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

        cout<<endl;

    }

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=2e5+5;

int a[N],n,x,y;

void work(){

    cin>>n>>x>>y;

    if(n&1){

        a[x]=2;

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

            x++;if(x==n+1)x=1;

            a[x]=(i&1);

        }

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

        cout<<endl;

        return;

    }

    for(int i=1;i<=n;i+=2)a[i]=1,a[i+1]=0;

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

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

        cout<<endl;

        return;

    }

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

        a[x]=2;

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

        cout<<endl;

        return;

    }

    a[x]=2;int xx=x;

    int fl=0;

    while(1){

        x++;if(x==n+1)x=1;

        if(x==y)break;

        if(fl==0)a[x]=0;

        if(fl==1)a[x]=2;

        if(fl>=2)a[x]=(fl-1)&1;

        fl++;

    }

    fl=0;x=xx;

    while(1){

        x--;if(x==0)x=n;

        if(x==y)break;

        a[x]=(fl-1)&1;

        fl++;

    }

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

    cout<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=2e5+5;

int a[N],n,x,y;

void work(){

    cin>>n>>x>>y;

    if(n&1){

        a[x]=2;

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

            x++;if(x==n+1)x=1;

            a[x]=(i&1);

        }

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

        cout<<endl;

        return;

    }

    for(int i=1;i<=n;i+=2)a[i]=1,a[i+1]=0;

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

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

        cout<<endl;

        return;

    }

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

        a[x]=2;

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

        cout<<endl;

        return;

    }

    a[x]=2;int xx=x;

    int fl=0;

    while(1){

        x++;if(x==n+1)x=1;

        if(x==y)break;

        if(fl==0)a[x]=0;

        if(fl==1)a[x]=2;

        if(fl>=2)a[x]=(fl-1)&1;

        fl++;

    }

    fl=0;x=xx;

    while(1){

        x--;if(x==0)x=n;

        if(x==y)break;

        a[x]=(fl-1)&1;

        fl++;

    }

    a[y]=1;

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

    cout<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=2e5+5;

int a[N],n,x,y;

void work(){

    cin>>n>>x>>y;

    if(n&1){

        a[x]=2;

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

            x++;if(x==n+1)x=1;

            a[x]=(i&1);

        }

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

        cout<<endl;

    }

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

        a[i]=1,a[i+1]=0;

    if(a[x]==a[y]||x+1==y||(y+1==x)||(x==1&&y==n)||(x==n&&y==1)){

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

        cout<<endl;

    }else{

        a[x]=2;int xx=x;

        int fl=0;

        while(1){

            x++;if(x==n+1)x=1;

            if(x==y)break;

            if(fl==0)a[x]=0;

            if(fl==1)a[x]=2;

            if(fl>=2)a[x]=(fl-1)&1;

            fl++;

        }

        fl=0;x=xx;

        while(1){

            x--;if(x==0)x=n;

            if(x==y)break;

            if(fl==0)a[x]=0;

            if(fl==1)a[x]=2;

            if(fl>=2)a[x]=(fl-1)&1;

            fl++;

        }

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

        cout<<endl;

    }

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}