ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;



#define ll long long





// void dfs(string curr, string &prev) {

//     if (curr > prev)  

//         prev = curr;



//     for (ll i = 1; i < curr.length(); i++) {

//         if (curr[i] == '0') continue;  

        

//         char ch = curr[i] - 1;

        

//         if (ch > curr[i - 1]) {  

            

//             curr[i] = ch;

//             swap(curr[i], curr[i - 1]);



//             dfs(curr, prev);  



//             swap(curr[i], curr[i - 1]);  

//             curr[i] +=1;

//         }

//     }

// }



void solve() {

    string s;

    cin >> s;

    

    ll n = s.size();

    

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

        for(ll j=n-1; j>=i; j--){

            if(s[j]=='0')

               continue;

            

            char ch = s[j] - 1;

            

            if(ch > s[j-1]){

                s[j] = ch;

                swap(s[j], s[j-1]);

            }

        

        }

    }

    

    cout<<s<<endl;

}



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    ll t;

    cin >> t;

    for (ll i = 0; i < t; i++) {

        solve();

    }

    return 0;

}











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

using namespace std;



#define ll long long



void solve() {

    string s;

    cin >> s;

    

    ll n = s.size();

    

    vector<ll>v(n);

    

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

       v[i] = s[i]-'0';

    

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

        

        ll j = i;

        while(j>=1 && v[j] > 0 && v[j] > v[j-1] + 1){

            v[j] -=1;

            swap(v[j], v[j-1]);

            j--;

        }

    }

    

    string res = "";

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

       res +=(v[i]+'0');

       

    cout<<res<<endl;

}



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    ll t;

    cin >> t;

    for (ll i = 0; i < t; i++) {

        solve();

    }

    return 0;

}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long
#define ld long double

void func(string a, string b, string c, string tmp, int pa, int pb, int pc, int &ans, int n, int m){
    if(pc == n + m){
        int cnt = 0;
        for(int i = 0; i < n + m; i++){
            if(tmp[i] != c[i]) cnt++;
        }
        ans = min(ans, cnt);
        return;
    }

    tmp += a[pa];
    pa++, pc++;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);
    tmp.pop_back();
    pa--, pc--;
    tmp += b[pb];
    pb++, pc++;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);
}

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;

    int n = a.size(), m = b.size();
    int ans = n + m;
    string tmp = "";
    int pa = 0, pb = 0, pc = 0;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);

    cout << ans << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    // solve();
}

Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double

void func(string a, string b, string c, string tmp, int pa, int pb, int pc, int &ans, int n, int m)
{
    if (pc == n + m)
    {
        int cnt = 0;
        for (int i = 0; i < n + m; i++)
        {
            if (tmp[i] != c[i])
                cnt++;
        }
        ans = min(ans, cnt);
        return;
    }

    if (pa < n)
    {
        tmp += a[pa];
        pa++, pc++;
        func(a, b, c, tmp, pa, pb, pc, ans, n, m);
        tmp.pop_back();
        pa--, pc--;
    }
    if (pb < m)
    {
        tmp += b[pb];
        pb++, pc++;
        func(a, b, c, tmp, pa, pb, pc, ans, n, m);
    }
}

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;

    int n = a.size(), m = b.size();
    int ans = n + m;
    string tmp = "";
    int pa = 0, pb = 0, pc = 0;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);

    cout << ans << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    // solve();
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double

void func(string a, string b, string c, string tmp, int pa, int pb, int pc, int &ans, int n, int m)
{
    if (pc == n + m)
    {
        int cnt = 0;
        for (int i = 0; i < n + m; i++)
        {
            if (tmp[i] != c[i])
                cnt++;
        }
        ans = min(ans, cnt);
        return;
    }

    if (pa < n)
    {
        tmp += a[pa];
        pa++, pc++;
        func(a, b, c, tmp, pa, pb, pc, ans, n, m);
        tmp.pop_back();
        pa--, pc--;
    }
    if (pb < m)
    {
        tmp += b[pb];
        pb++, pc++;
        func(a, b, c, tmp, pa, pb, pc, ans, n, m);
    }
}

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;

    int n = a.size(), m = b.size();
    int ans = n + m;
    string tmp = "";
    int pa = 0, pb = 0, pc = 0;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);

    cout << ans << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    // solve();
}

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

using namespace std;

#define int long long
#define ld long double

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;

    int n = a.size(), m = b.size();
    int mx = 1e5;
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, mx));

    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
    }

    for(int i = 1; i <= m; i++){
        dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]), dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
        }
    }

    cout << dp[n][m] << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    // solve();
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


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

using namespace std;

#define int long long
#define ld long double

void func(string a, string b, string c, string tmp, int pa, int pb, int pc, int &ans, int n, int m){
    if(pc == n + m){
        int cnt = 0;
        for(int i = 0; i < n + m; i++){
            if(tmp[i] != c[i]) cnt++;
        }
        ans = min(ans, cnt);
        return;
    }

    tmp += a[pa];
    pa++, pc++;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);
    tmp.pop_back();
    pa--, pc--;
    tmp += b[pb];
    pb++, pc++;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);
}

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;

    int n = a.size(), m = b.size();
    int ans = n + m;
    string tmp = "";
    int pa = 0, pb = 0, pc = 0;
    func(a, b, c, tmp, pa, pb, pc, ans, n, m);

    cout << ans << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    // solve();
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Memory limit exceeded on test 3):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while(t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    map<int, int> ava;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      ava[a[i]]++;
    }
    for(int i = 0; i < m; i++){
      cin >> b[i];
    }
    bool pos = true;
    for(int i = 0; i < m; i++){
      stack<int> now;
      now.push(b[i]);
      int c = 0;
      int s = 0;
      while(!now.empty()){
        int top = now.top();
        if(s == b[i]) break;
        //cout << top << "\n";
        if(c == 2 && !now.empty()){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          if(now.empty()) break;
          c = 0;
        }
        if(ava[now.top()]){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          c++;
          continue;
        }
        if(now.top() == 1 && ava[1] == 0){
          pos = false;
          break;
        }
        now.push(top / 2);
        now.push(ceil(top / 2.0));
      }
    }
    for(auto as: ava){
      if(as.second){
        pos = false;
        break;
      }
    }
    cout << (pos? "Yes":"No") << "\n";
  }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while(t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    map<int, int> ava;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      ava[a[i]]++;
    }
    for(int i = 0; i < m; i++){
      cin >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    bool pos = true;
    for(int i = 0; i < m; i++){
      stack<int> now;
      now.push(b[i]);
      int c = 0;
      int s = 0;
      while(!now.empty()){
        if(now.top() == 0){
          pos = false;
          break;
        }
        int top = now.top();
        now.pop();
        if(s == b[i]) break;
        //cout << top << "\n";
        if(c == 2 && !now.empty()){
          ava[top]--;
          s += top;
          if(now.empty()) break;
          c = 0;
        }
        if(ava[top]){
          ava[top]--;
          s += top;
          c++;
          continue;
        }
        if(top == 1 && ava[1] == 0){
          pos = false;
          break;
        }
        now.push(top / 2);
        now.push(ceil(top / 2.0));
      }
    }
    for(auto as: ava){
      if(as.second){
        pos = false;
        break;
      }
    }
    cout << (pos? "Yes":"No") << "\n";
  }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while(t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    map<int, int> ava;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      ava[a[i]]++;
    }
    for(int i = 0; i < m; i++){
      cin >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    bool pos = true;
    for(int i = 0; i < m; i++){
      stack<int> now;
      now.push(b[i]);
      int c = 0;
      int s = 0;
      while(!now.empty()){
        if(now.top() == 0){
          pos = false;
          break;
        }
        int top = now.top();
        now.pop();
        if(s == b[i]) break;
        //cout << top << "\n";
        // if(c == 2 && !now.empty()){
        //   ava[top]--;
        //   s += top;
        //   if(now.empty()) break;
        //   c = 0;
        // }
        if(ava[top]){
          ava[top]--;
          s += top;
          c++;
          continue;
        }
        if(top == 1 && ava[1] == 0){
          pos = false;
          break;
        }
        now.push(top / 2);
        now.push(ceil(top / 2.0));
      }
    }
    for(auto as: ava){
      if(as.second){
        pos = false;
        break;
      }
    }
    cout << (pos? "Yes":"No") << "\n";
  }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while(t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    map<int, int> ava;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      ava[a[i]]++;
    }
    for(int i = 0; i < m; i++){
      cin >> b[i];
    }
    bool pos = true;
    for(int i = 0; i < m; i++){
      stack<int> now;
      now.push(b[i]);
      int c = 0;
      int s = 0;
      while(!now.empty()){
        if(now.top() == 0){
          pos = false;
          break;
        }
        int top = now.top();
        if(s == b[i]) break;
        //cout << top << "\n";
        if(c == 2 && !now.empty()){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          if(now.empty()) break;
          c = 0;
        }
        if(ava[now.top()]){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          c++;
          continue;
        }
        if(now.top() == 1 && ava[1] == 0){
          pos = false;
          break;
        }
        now.push(top / 2);
        now.push(ceil(top / 2.0));
      }
    }
    for(auto as: ava){
      if(as.second){
        pos = false;
        break;
      }
    }
    cout << (pos? "Yes":"No") << "\n";
  }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while(t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    map<int, int> ava;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      ava[a[i]]++;
    }
    for(int i = 0; i < m; i++){
      cin >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    bool pos = true;
    for(int i = 0; i < m; i++){
      stack<int> now;
      now.push(b[i]);
      int c = 0;
      int s = 0;
      while(!now.empty()){
        if(now.top() == 0){
          pos = false;
          break;
        }
        int top = now.top();
        now.pop();
        if(s == b[i]) break;
        //cout << top << "\n";
        if(c == 2 && !now.empty()){
          ava[top]--;
          s += top;
          if(now.empty()) break;
          c = 0;
        }
        if(ava[top]){
          ava[top]--;
          s += top;
          c++;
          continue;
        }
        if(top == 1 && ava[1] == 0){
          pos = false;
          break;
        }
        now.push(top / 2);
        now.push(ceil(top / 2.0));
      }
    }
    for(auto as: ava){
      if(as.second){
        pos = false;
        break;
      }
    }
    cout << (pos? "Yes":"No") << "\n";
  }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Memory limit exceeded on test 3):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while(t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    map<int, int> ava;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      ava[a[i]]++;
    }
    for(int i = 0; i < m; i++){
      cin >> b[i];
    }
    bool pos = true;
    for(int i = 0; i < m; i++){
      stack<int> now;
      now.push(b[i]);
      int c = 0;
      int s = 0;
      while(!now.empty()){
        int top = now.top();
        if(s == b[i]) break;
        //cout << top << "\n";
        if(c == 2 && !now.empty()){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          if(now.empty()) break;
          c = 0;
        }
        if(ava[now.top()]){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          c++;
          continue;
        }
        if(now.top() == 1 && ava[1] == 0){
          pos = false;
          break;
        }
        now.push(top / 2);
        now.push(ceil(top / 2.0));
      }
    }
    for(auto as: ava){
      if(as.second){
        pos = false;
        break;
      }
    }
    cout << (pos? "Yes":"No") << "\n";
  }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while(t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    map<int, int> ava;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      ava[a[i]]++;
    }
    for(int i = 0; i < m; i++){
      cin >> b[i];
    }
    bool pos = true;
    for(int i = 0; i < m; i++){
      stack<int> now;
      now.push(b[i]);
      int c = 0;
      int s = 0;
      while(!now.empty()){
        if(now.top() == 0){
          pos = false;
          break;
        }
        int top = now.top();
        if(s == b[i]) break;
        //cout << top << "\n";
        if(c == 2 && !now.empty()){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          if(now.empty()) break;
          c = 0;
        }
        if(ava[now.top()]){
          ava[now.top()]--;
          s += now.top();
          now.pop();
          c++;
          continue;
        }
        if(now.top() == 1 && ava[1] == 0){
          pos = false;
          break;
        }
        now.push(top / 2);
        now.push(ceil(top / 2.0));
      }
    }
    for(auto as: ava){
      if(as.second){
        pos = false;
        break;
      }
    }
    cout << (pos? "Yes":"No") << "\n";
  }
}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 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;

    

    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+1]={0};

    int curr = 1;

    p[x]=0;

    p[y]=1;

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

    p[0]=p[n];

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

    p[y]=2;

    

    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;

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

Previous submission (verdict: Wrong answer on test 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;

}

Submission (verdict: Accepted):
#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;

}