ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: Java 8


Submission (verdict: Wrong answer on test 1):
import java.util.*;
public class ProblemC {

    static long mod = (long)(1e9+7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int num = 0;
            for(int i =30;i>=0;i--) {
                if(((l&(1<<i))>0 && (r&(1<<i))>0)) {
                    num|=(1<<i);
                } else if(((l&(1<<i))==0 && (r&(1<<i))==0)) {
                    continue;
                } else {
                    num|=(1<<i);
                    break;
                }
            }

            int a = num;
            int b = num-1;
            int c = l;
            System.out.println(a+" "+b+" "+c);
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: Java 8

Previous submission (verdict: Wrong answer on test 1):
import java.util.*;
public class ProblemC {

    static long mod = (long)(1e9+7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if(r-l == 2) {
                System.out.println(r+" "+(r+1)+" "+l);
                continue;
            }
            int num = 0;
            for(int i =30;i>=0;i--) {
                if(((l&(1<<i))>0 && (r&(1<<i))>0)) {
                    num|=(1<<i);
                } else if(((l&(1<<i))==0 && (r&(1<<i))==0)) {
                    continue;
                } else {
                    num|=(1<<i);
                    break;
                }
            }

            int a = num;
            int b = num-1;
            int c = l;
            System.out.println(a+" "+b+" "+c);
        }
    }
}

Submission (verdict: Wrong answer on test 2):
import java.util.*;
public class ProblemC {

    static long mod = (long)(1e9+7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if(r-l == 2) {
                System.out.println(r+" "+(r-1)+" "+l);
                continue;
            }
            int num = 0;
            for(int i =30;i>=0;i--) {
                if(((l&(1<<i))>0 && (r&(1<<i))>0)) {
                    num|=(1<<i);
                } else if(((l&(1<<i))==0 && (r&(1<<i))==0)) {
                    continue;
                } else {
                    num|=(1<<i);
                    break;
                }
            }

            int a = num;
            int b = num-1;
            int c = l;
            System.out.println(a+" "+b+" "+c);
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: Java 8

Previous submission (verdict: Wrong answer on test 1):
import java.util.*;
public class ProblemC {

    static long mod = (long)(1e9+7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int num = 0;
            for(int i =30;i>=0;i--) {
                if(((l&(1<<i))>0 && (r&(1<<i))>0)) {
                    num|=(1<<i);
                } else if(((l&(1<<i))==0 && (r&(1<<i))==0)) {
                    continue;
                } else {
                    num|=(1<<i);
                    break;
                }
            }

            int a = num;
            int b = num-1;
            int c = l;
            System.out.println(a+" "+b+" "+c);
        }
    }
}

Submission (verdict: Wrong answer on test 1):
import java.util.*;
public class ProblemC {

    static long mod = (long)(1e9+7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if(r-l == 2) {
                System.out.println(r+" "+(r+1)+" "+l);
                continue;
            }
            int num = 0;
            for(int i =30;i>=0;i--) {
                if(((l&(1<<i))>0 && (r&(1<<i))>0)) {
                    num|=(1<<i);
                } else if(((l&(1<<i))==0 && (r&(1<<i))==0)) {
                    continue;
                } else {
                    num|=(1<<i);
                    break;
                }
            }

            int a = num;
            int b = num-1;
            int c = l;
            System.out.println(a+" "+b+" "+c);
        }
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

int solve(string a, string b, string c, string x, int i, int j, int na, int nb, int &maxi) {

    if(i == na && j == nb) {
        int cnt = 0;
        for(int k = 0; k < na + nb; k++) {
            if(x[k] != c[k]) cnt++;
        }
        maxi = min(maxi, cnt);
        return maxi;
    }

    if(i < na) solve(a, b, c, x + a[i], i + 1, j, na, nb, maxi);
    if(j < nb) solve(a, b, c, x + b[j], i, j + 1, na, nb, maxi);

    return maxi;  
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;
        string x = "";
        int maxi = INT_MAX;
        int y = solve(a, b, c, x, 0, 0, a.length(), b.length(), maxi);
        cout << y << "\n";
    }
    return 0;
}



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

int solve(string& a, string &b, string& c, string x, int i, int j, int na, int nb, int &maxi) {

    if(i == na && j == nb) {
        int cnt = 0;
        for(int k = 0; k < na + nb; k++) {
            if(x[k] != c[k]) cnt++;
        }
        maxi = min(maxi, cnt);
        return maxi;
    }

    if(i < na) solve(a, b, c, x + a[i], i + 1, j, na, nb, maxi);
    if(j < nb) solve(a, b, c, x + b[j], i, j + 1, na, nb, maxi);

    return maxi;  
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;
        string x = "";
        int maxi = INT_MAX;
        int y = solve(a, b, c, x, 0, 0, a.length(), b.length(), maxi);
        cout << y << "\n";
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


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

int solve(string a, string b, string c, string x, int i, int j, int na, int nb, int &maxi) {

    if(i == na && j == nb) {
        int cnt = 0;
        for(int k = 0; k < na + nb; k++) {
            if(x[k] != c[k]) cnt++;
        }
        maxi = min(maxi, cnt);
        return maxi;
    }

    if(i < na) solve(a, b, c, x + a[i], i + 1, j, na, nb, maxi);
    if(j < nb) solve(a, b, c, x + b[j], i, j + 1, na, nb, maxi);

    return maxi;  
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;
        string x = "";
        int maxi = INT_MAX;
        int y = solve(a, b, c, x, 0, 0, a.length(), b.length(), maxi);
        cout << y << "\n";
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

int solve(string& a, string &b, string& c, string x, int i, int j, int na, int nb, int &maxi) {

    if(i == na && j == nb) {
        int cnt = 0;
        for(int k = 0; k < na + nb; k++) {
            if(x[k] != c[k]) cnt++;
        }
        maxi = min(maxi, cnt);
        return maxi;
    }

    if(i < na) solve(a, b, c, x + a[i], i + 1, j, na, nb, maxi);
    if(j < nb) solve(a, b, c, x + b[j], i, j + 1, na, nb, maxi);

    return maxi;  
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;
        string x = "";
        int maxi = INT_MAX;
        int y = solve(a, b, c, x, 0, 0, a.length(), b.length(), maxi);
        cout << y << "\n";
    }
    return 0;
}



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

vector<vector<int>> dp;

int solve(string &a, string &b, string &c, int i, int j, int na, int nb) {
    if (i == na && j == nb) {
        return 0;
    }

    if (dp[i][j] != -1) return dp[i][j];
    int pos = i + j;
    int res = 1e9;

    if (i < na) {
        int cost = solve(a, b, c, i + 1, j, na, nb) + (a[i] != c[pos]);
        res = min(res, cost);
    }

    if (j < nb) {
        int cost = solve(a, b, c, i, j + 1, na, nb) + (b[j] != c[pos]);
        res = min(res, cost);
    }

    return dp[i][j] = res;
}

int main() {
    int t;
    cin >> t;

    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;

        int na = a.length(), nb = b.length();
        dp.assign(na + 1, vector<int>(nb + 1, -1));  

        int y = solve(a, b, c, 0, 0, na, nb);
        cout << y << "\n";
    }

    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
 
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define PI pair<int,int>
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define dbgl(x) cout << #x << " = " << x << "####" << endl;
#define dbg(x) cout << #x << " = " << x << " ";

const int INF = 1e16;
const int MAX = 1e3+10;

int memo[MAX][MAX];

string a, b, c;

int dp(int ia, int ib){
	if(ia == a.size() and ib == b.size()) return 0;
	if(memo[ia][ib] != -1) return memo[ia][ib];

	if(ia == a.size()){
		if(b[ib] == c[ia+ib]) return memo[ia][ib] = dp(ia, ib+1);
		return memo[ia][ib] = dp(ia, ib+1) + 1;
	}

	if(ib == b.size()){
		if(a[ia] == c[ia+ib]) return memo[ia][ib] = dp(ia+1, ib);
		return memo[ia][ib] = dp(ia+1, ib) + 1;
	}

	if(a[ia] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib), dp(ia, ib+1) + 1);
	if(b[ib] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1));
	return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1) + 1);
}

int32_t main(){ _
    int t; cin >> t;
	while(t--){
		cin >> a >> b >> c;
		memset(memo, -1, sizeof(memo));
		int ans = dp(0, 0);
		cout << ans << endl;
	}
    
}   

/* makefile
CXX = g++
CPXXFLAGS = -fsanitize=address,undefined -fno-omit-frame-pointer -g -Wall -Wshadow -std=c++17 -Wno-unused-result -Wno-sign-compare -Wno-char-subscripts #-fuse-ld=gold

q:	
		cp makefiletemp.cpp $(f).cpp
		touch $(f).txt
		code $(f).txt        
		code $(f).cpp
		clear
compile: 
		g++ -g $(f).cpp $(CXXFLAGS) -o $(f)
exe:
		./$(f) < $(f).txt

runc: compile
comp: compile exe

clearexe:
		find . -maxdepth 1 -type f -executable -exec rm {} +
cleartxt:
		find . -type f -name "*.txt" -exec rm -f {} \; 
clear: clearexe cleartxt
		clear
*/
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    if(s.size()==1){

        cout<<s<<endl;

        return ;

    }

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

    

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

        bool flag=0;

        if(i+1<n&&v[i+1]!=0&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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

    

    int t;cin>>t;

    while(t--) solve();



}

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    if(s.size()==1){

        cout<<s<<endl;

        return ;

    }

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

    bool flag=0;

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

        // bool flag=0;

        if(i+1<n&&v[i+1]!=0&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

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

            if(flag) flag=0;

            else break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}

//2247

//my:2532

//an:4232



signed main(){

    ios::sync_with_stdio(0);

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

    

    int t;cin>>t;

    while(t--) solve();



}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    if(s.size()==1){

        cout<<s<<endl;

        return ;

    }

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

    

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

        bool flag=0;

        if(i+1<n&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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

    

    int t;cin>>t;

    while(t--) solve();



}

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    if(s.size()==1){

        cout<<s<<endl;

        return ;

    }

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

    

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

        bool flag=0;

        if(i+1<n&&v[i+1]!=0&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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

    

    int t;cin>>t;

    while(t--) solve();



}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

    if(n==1){

        cout<<v.back()<<endl;

        return ;

    }

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

        bool flag=0;

        if(i+1<n&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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

    

    int t;cin>>t;

    while(t--) solve();



}

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    if(s.size()==1){

        cout<<s<<endl;

        return ;

    }

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

    

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

        bool flag=0;

        if(i+1<n&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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

    

    int t;cin>>t;

    while(t--) solve();



}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

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

        bool flag=0;

        if(i+1<n&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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



    int t;cin>>t;

    while(t--) solve();



}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

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

        bool flag=0;

        if(i+1<n&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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



    int t;cin>>t;

    while(t--) solve();



}

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

using namespace std;

#define int long long 

#define pii pair<int,int>

#define endl '\n'

const int N=2e5+10;

int a[N];



void solve(){

    string s;cin>>s;

    vector<int>v;

    for(auto c:s) v.push_back(c-'0');

    int n=v.size();

    if(n==1){

        cout<<v.back()<<endl;

        return ;

    }

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

        bool flag=0;

        if(i+1<n&&v[i+1]-2>=v[i]){

            v[i+1]--;

            swap(v[i],v[i+1]);

            flag=1;

        }

        if(i+1==n-1&&flag==0){

            break;

        }

    }

    for(auto x:v) cout<<x;

    cout<<endl;

}



signed main(){

    ios::sync_with_stdio(0);

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

    

    int t;cin>>t;

    while(t--) solve();



}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
#define endl '\n'
const int N=1e5+10;
//int a[N];

void solve() {
    int l,r;cin>>l>>r;
    int k=31-__builtin_clz(r);//找到最高位的下标
    int a=0;
    while((l>>k&1)==(r>>k&1)){
        a+=(r>>k&1)<<k;
        k--;
    }
    a+=1<<k;
    int b=a-1;
    cout<<a<<' '<<b<<' '<<l<<endl;
    //cout<<(a^b)+(b^l)+(a^l)<<endl;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

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

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
#define endl '\n'
const int N=1e5+10;
//int a[N];

void solve() {
    int l,r;cin>>l>>r;
    int k=31-__builtin_clz(r);//找到最高位的下标
    int a=0;
    while((l>>k&1)==(r>>k&1)){
        a+=(r>>k&1)<<k;
        k--;
    }
    a+=1<<k;
    int b=a-1;
    if(b==l){
        cout<<l<<' '<<a<<' '<<a+1<<endl;
    }else  cout<<a<<' '<<b<<' '<<l<<endl;
    //cout<<(a^b)+(b^l)+(a^l)<<endl;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

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

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
#define endl '\n'
const int N=1e5+10;
//int a[N];




void solve() {
    int l, r;
    cin >> l >> r;  // 输入两个整数 l 和 r

    // 计算 l 和 r 异或后的结果，并找出该结果中最高位的二进制位置
    int k = 0;
    for (int i = 30; i >= 0; --i) {
        if ((l ^ r) & (1 << i)) {
            k = i;
            break;
        }
    }

    // a 是 l 的高位部分保持不变，低位部分变为全 1
    int a = l | ((1 << (k + 1)) - 1);
    // b 是 a 的下一个整数
    int b = a + 1;
    // 如果 a 和 l 相同，c 就是 r，否则 c 就是 l
    int c = (a == l ? r : l);

    // 输出结果
    cout << a << " " << b << " " << c << "\n";
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    int t=1;
    while(t--) solve();

}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
#define endl '\n'
const int N=1e5+10;
//int a[N];

void solve() {
    int l,r;cin>>l>>r;
    int k=31-__builtin_clz(r);//找到最高位的下标
    int a=0;
    while((l>>k&1)==(r>>k&1)){
        a+=(r>>k&1)<<k;
        k--;
    }
    a+=1<<k;
    int b=a-1;
    cout<<a<<' '<<b<<' '<<l<<endl;
    //cout<<(a^b)+(b^l)+(a^l)<<endl;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

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

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
#define endl '\n'
const int N=1e5+10;
//int a[N];




void solve() {
    int l, r;
    cin >> l >> r;  // 输入两个整数 l 和 r

    // 计算 l 和 r 异或后的结果，并找出该结果中最高位的二进制位置
    int k = 0;
    for (int i = 30; i >= 0; --i) {
        if ((l ^ r) & (1 << i)) {
            k = i;
            break;
        }
    }

    // a 是 l 的高位部分保持不变，低位部分变为全 1
    int a = l | ((1 << (k + 1)) - 1);
    // b 是 a 的下一个整数
    int b = a + 1;
    // 如果 a 和 l 相同，c 就是 r，否则 c 就是 l
    int c = (a == l ? r : l);

    // 输出结果
    cout << a << " " << b << " " << c << "\n";
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

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

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
#define endl '\n'
const int N=1e5+10;
//int a[N];




void solve() {
    int l, r;
    cin >> l >> r;  // 输入两个整数 l 和 r

    // 计算 l 和 r 异或后的结果，并找出该结果中最高位的二进制位置
    int k = 0;
    for (int i = 30; i >= 0; --i) {
        if ((l ^ r) & (1 << i)) {
            k = i;
            break;
        }
    }

    // a 是 l 的高位部分保持不变，低位部分变为全 1
    int a = l | ((1 << (k + 1)) - 1);
    // b 是 a 的下一个整数
    int b = a + 1;
    // 如果 a 和 l 相同，c 就是 r，否则 c 就是 l
    int c = (a == l ? r : l);

    // 输出结果
    cout << a << " " << b << " " << c << "\n";
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

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

}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pii pair<int,int>
#define endl '\n'
const int N=1e5+10;
//int a[N];




void solve() {
    int l, r;
    cin >> l >> r;  // 输入两个整数 l 和 r

    // 计算 l 和 r 异或后的结果，并找出该结果中最高位的二进制位置
    int k = 0;
    for (int i = 30; i >= 0; --i) {
        if ((l ^ r) & (1 << i)) {
            k = i;
            break;
        }
    }

    // a 是 l 的高位部分保持不变，低位部分变为全 1
    int a = l | ((1 << (k + 1)) - 1);
    // b 是 a 的下一个整数
    int b = a + 1;
    // 如果 a 和 l 相同，c 就是 r，否则 c 就是 l
    int c = (a == l ? r : l);

    // 输出结果
    cout << a << " " << b << " " << c << "\n";
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    int t=1;
    while(t--) solve();

}