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

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
typedef pair<int,int> PII;
typedef priority_queue<int> dheap;
typedef priority_queue<int,vector<int>,greater<int> > xheap;
#define all(a) a.begin(),a.end()
const int N=2e5+10,M=2e5;
const int Size=2e5+10+1;



void solve(){
    int m;
    cin>>m;
    vi p(m);
    vii adj(m+1,vi(m+1));
    vii st(m+1,vi(m+1));
    int ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<m;i++){
        for(int j=i+1;j<m;j++){
            if(p[i]>p[j]){
                adj[p[i]][p[j]]=1;ans++;
            }else ans+=2;
        }
    }cout<<ans<<"\n";
    vi pp(m);
    for(int i=0;i<m;i++)pp[i]=i+1;
    for(int i=0;i<m-1;i++){
        for(int j=0;j<m-1-i;j++){
            if(pp[j]<pp[j+1]&&adj[pp[j+1]][pp[j]]){
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                st[pp[j+1]][pp[j]]=st[pp[j]][pp[j+1]]=1;
                adj[pp[j+1]][pp[j]]=0;
                swap(pp[j],pp[j+1]);
            }
            else if(!st[pp[j]][pp[j+1]]){
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                cout<<pp[j]<<" "<<pp[j+1]<<"\n";
            }
        }
    }
}

int main() {
    #ifdef Online_Judge
    freopen("INPUT.in","r",stdin); 
    freopen("OUTPUT.out","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
typedef pair<int,int> PII;
typedef priority_queue<int> dheap;
typedef priority_queue<int,vector<int>,greater<int> > xheap;
#define all(a) a.begin(),a.end()
const int N=2e5+10,M=2e5;
const int Size=2e5+10+1;



void solve(){
    int m;
    cin>>m;
    vi p(m);
    vii st(m+1,vi(m+1,2));
    int ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
            if(p[i]>p[j]){
                st[p[i]][p[j]]--;ans++;
            }else ans+=2;
        }
    }cout<<ans<<"\n";
    vi pp(m);
    for(int i=0;i<m;i++)pp[i]=i+1;
    while(ans){
        for(int j=0;j<m-1;j++){
            if(st[pp[j+1]][pp[j]]){
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                st[pp[j+1]][pp[j]]--;
                swap(pp[j],pp[j+1]);ans--;
            }
            else if(st[pp[j]][pp[j+1]]){
                st[pp[j]][pp[j+1]]--;
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                swap(pp[j],pp[j+1]);ans--;
            }
        }
    }
}

int main() {
    #ifdef Online_Judge
    freopen("INPUT.in","r",stdin); 
    freopen("OUTPUT.out","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
typedef pair<int,int> PII;
typedef priority_queue<int> dheap;
typedef priority_queue<int,vector<int>,greater<int> > xheap;
#define all(a) a.begin(),a.end()
const int N=2e5+10,M=2e5;
const int Size=2e5+10+1;



void solve(){
    int m;
    cin>>m;
    vi p(m);
    vii st(m+1,vi(m+1,2));
    int ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
            if(p[i]>p[j]){
                st[p[i]][p[j]]--;ans++;
            }else ans+=2;
        }
    }cout<<ans<<"\n";
    vi pp(m);
    for(int i=0;i<m;i++)pp[i]=i+1;
    while(ans){
        for(int j=0;j<m-1;j++){
            if(st[pp[j+1]][pp[j]]){
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                st[pp[j+1]][pp[j]]--;
                swap(pp[j],pp[j+1]);ans--;
            }
            else if(st[pp[j]][pp[j+1]]){
                st[pp[j]][pp[j+1]]--;
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                swap(pp[j],pp[j+1]);ans--;
            }
        }
    }
}

int main() {
    #ifdef Online_Judge
    freopen("INPUT.in","r",stdin); 
    freopen("OUTPUT.out","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
typedef pair<int,int> PII;
typedef priority_queue<int> dheap;
typedef priority_queue<int,vector<int>,greater<int> > xheap;
#define all(a) a.begin(),a.end()
const int N=2e5+10,M=2e5;
const int Size=2e5+10+1;



void solve(){
    int m;
    cin>>m;
    vi p(m);
    vii st(m+1,vi(m+1,1));
    int ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
            if(p[i]>p[j]){
                st[p[i]][p[j]]--;ans++;
            }else ans+=2;
        }
    }cout<<ans<<"\n";
    vi pp(m);
    for(int i=0;i<m;i++)pp[i]=i+1;
    while(ans){
        for(int j=0;j<m-1;j++){
            if(st[pp[j]][pp[j+1]]){
                cout<<pp[j]<<" "<<pp[j+1]<<"\n";
                st[pp[j]][pp[j+1]]--;
                swap(pp[j],pp[j+1]);ans--;
            }
        }
    }
}

int main() {
    #ifdef Online_Judge
    freopen("INPUT.in","r",stdin); 
    freopen("OUTPUT.out","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
typedef pair<int,int> PII;
typedef priority_queue<int> dheap;
typedef priority_queue<int,vector<int>,greater<int> > xheap;
#define all(a) a.begin(),a.end()
const int N=2e5+10,M=2e5;
const int Size=2e5+10+1;



void solve(){
    int m;
    cin>>m;
    vi p(m);
    vii adj(m+1,vi(m+1));
    vii st(m+1,vi(m+1));
    int ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<m;i++){
        for(int j=i+1;j<m;j++){
            if(p[i]>p[j]){
                adj[p[i]][p[j]]=1;ans++;
            }else ans+=2;
        }
    }cout<<ans<<"\n";
    vi pp(m);
    for(int i=0;i<m;i++)pp[i]=i+1;
    for(int i=0;i<m-1;i++){
        for(int j=0;j<m-1-i;j++){
            if(pp[j]<pp[j+1]&&adj[pp[j+1]][pp[j]]){
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                st[pp[j+1]][pp[j]]=st[pp[j]][pp[j+1]]=1;
                adj[pp[j+1]][pp[j]]=0;
                swap(pp[j],pp[j+1]);
            }
            else if(!st[pp[j]][pp[j+1]]){
                cout<<pp[j+1]<<" "<<pp[j]<<"\n";
                cout<<pp[j]<<" "<<pp[j+1]<<"\n";
            }
        }
    }
}

int main() {
    #ifdef Online_Judge
    freopen("INPUT.in","r",stdin); 
    freopen("OUTPUT.out","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
typedef pair<int,int> PII;
typedef priority_queue<int> dheap;
typedef priority_queue<int,vector<int>,greater<int> > xheap;
#define all(a) a.begin(),a.end()
const int N=2e5+10,M=2e5;
const int Size=2e5+10+1;



void solve(){
    int m;
    cin>>m;
    vi p(m);
    vii st(m+1,vi(m+1,1));
    int ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
            if(p[i]>p[j]){
                st[p[i]][p[j]]--;ans++;
            }else ans+=2;
        }
    }cout<<ans<<"\n";
    vi pp(m);
    for(int i=0;i<m;i++)pp[i]=i+1;
    while(ans){
        for(int j=0;j<m-1;j++){
            if(st[pp[j]][pp[j+1]]){
                cout<<pp[j]<<" "<<pp[j+1]<<"\n";
                st[pp[j]][pp[j+1]]--;
                swap(pp[j],pp[j+1]);ans--;
            }
        }
    }
}

int main() {
    #ifdef Online_Judge
    freopen("INPUT.in","r",stdin); 
    freopen("OUTPUT.out","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define MAX_SIZE 100
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> vll;
typedef pair<int,int> PII;
typedef priority_queue<int> dheap;
typedef priority_queue<int,vector<int>,greater<int> > xheap;
#define all(a) a.begin(),a.end()
const int N=2e5+10,M=2e5;
const int Size=2e5+10+1;



void solve(){
    int m;
    cin>>m;
    vi p(m);
    vii st(m+1,vi(m+1,1));
    int ans=0;
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
            if(p[i]>p[j]){
                st[p[j]][p[i]]--;ans++;
            }else ans+=2;
        }
    }cout<<ans<<"\n";
    vi pp(m);
    for(int i=0;i<m;i++)pp[i]=i+1;
    while(ans){
        for(int i=m-1;i;i--){
            if(st[pp[i]][pp[i-1]]){
                cout<<pp[i]<<' '<<pp[i-1]<<'\n';
                st[pp[i]][pp[i-1]]--;ans--;swap(pp[i],pp[i-1]);
            }
        }
    }
}

int main() {
    #ifdef Online_Judge
    freopen("INPUT.in","r",stdin); 
    freopen("OUTPUT.out","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define int int64_t

typedef pair<int,int> pii;

void sol()

{

    string a,b,c;

    cin>>a>>b>>c;

    int k=a.size();

    int n=c.size();

    int w=b.size();

    a=" "+a;b=" "+b;c=" "+c;

    int dp[n+1][k+1];

    memset(dp,0,sizeof dp);



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

        for(int j=max((int)0,i-w);j<=min(k,i);j++)

        {

            dp[i][j]=dp[i-1][j]+(b[i-j]!=c[i]);

            if(j>=1)

            dp[i][j]=min(dp[i-1][j-1]+(a[j]!=c[i]),dp[i][j]);

        }

    int ans=dp[n][k];

    cout<<ans<<endl;

}

signed main(void)

{

    int t;

    cin>>t;

    while(t--)

        sol();

    return 0;

}



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

using namespace std;

#define int int64_t

typedef pair<int,int> pii;

void sol()

{

    string a,b,c;

    cin>>a>>b>>c;

    int k=a.size();

    int n=c.size();

    int w=b.size();

    a=" "+a;b=" "+b;c=" "+c;

    int dp[n+1][k+1];

    memset(dp,0,sizeof dp);



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

        for(int j=max((int)0,i-w);j<=min(k,i);j++)

        {

            dp[i][j]=dp[i-1][j]+(b[i-j]==c[i]);

            if(j>=1)

            dp[i][j]=max(dp[i-1][j-1]+(a[j]==c[i]),dp[i][j]);

        }

    int ans=dp[n][k];

    cout<<n-ans<<endl;

}

signed main(void)

{

    int t;

    cin>>t;

    while(t--)

        sol();

    return 0;

}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define int int64_t

typedef pair<int,int> pii;

void sol()

{

    string a,b,c;

    cin>>a>>b>>c;

    int k=a.size();

    int n=c.size();

    a=" "+a;b=" "+b;c=" "+c;

    int dp[n+1][k+1];

    memset(dp,0,sizeof dp);

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

        for(int j=0;j<=min(k,i);j++)

        {

            dp[i][j]=dp[i-1][j]+(b[i-j]!=c[i]);

            if(j>=1)

            dp[i][j]=min(dp[i-1][j-1]+(a[j]!=c[i]),dp[i][j]);

        }

    int ans=dp[n][k];

    cout<<ans<<endl;

}

signed main(void)

{

    int t;

    cin>>t;

    while(t--)

        sol();

    return 0;

}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define int int64_t

typedef pair<int,int> pii;

void sol()

{

    string a,b,c;

    cin>>a>>b>>c;

    int k=a.size();

    int n=c.size();

    a=" "+a;b=" "+b;c=" "+c;

    int dp[n+1][k+1];

    memset(dp,0,sizeof dp);

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

        for(int j=0;j<=min(k,i);j++)

        {

            dp[i][j]=dp[i-1][j]+(b[i-j]!=c[i]);

            if(j>=1)

            dp[i][j]=min(dp[i-1][j-1]+(a[j]!=c[i]),dp[i][j]);

        }

    int ans=dp[n][k];

    cout<<ans<<endl;

}

signed main(void)

{

    int t;

    cin>>t;

    while(t--)

        sol();

    return 0;

}



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

using namespace std;

#define int int64_t

typedef pair<int,int> pii;

void sol()

{

    string a,b,c;

    cin>>a>>b>>c;

    int k=a.size();

    int n=c.size();

    int w=b.size();

    a=" "+a;b=" "+b;c=" "+c;

    int dp[n+1][k+1];

    memset(dp,0,sizeof dp);



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

        for(int j=max((int)0,i-w);j<=min(k,i);j++)

        {

            dp[i][j]=dp[i-1][j]+(b[i-j]!=c[i]);

            if(j>=1)

            dp[i][j]=min(dp[i-1][j-1]+(a[j]!=c[i]),dp[i][j]);

        }

    int ans=dp[n][k];

    cout<<ans<<endl;

}

signed main(void)

{

    int t;

    cin>>t;

    while(t--)

        sol();

    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    vector<pii>ans;
    for(int i=n;i;i--)
    {
        for(int j=1;j<i;j++)
        {
            ans.push_back({a[j],a[i]});
            if(a[i]>=a[j])
            {
                ans.push_back({a[i],a[j]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.first<<" "<<x.second<<endl;
}
signed main()
{

    sol();
return 0;
}


Submission (verdict: Wrong answer on test 5):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    vector<pii>ans;
    for(int i=n;i;i--)
    {
        for(int j=1;j<i;j++)
        {
            if(a[i]<a[j])
            ans.push_back({a[j],a[i]});
        }
    }
    for(int i=1;i<=n;i++)
    {
        stack<pii>st;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]<a[i])break;
            st.push({a[j],a[i]});
            ans.push_back({a[j],a[i]});
        }
        while(st.size())
        {
            auto x=st.top();
            swap(x.first,x.second);
            ans.push_back(x);
            st.pop();
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.first<<" "<<x.second<<endl;
}
signed main()
{

    sol();
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 5):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    vector<pii>ans;
    for(int i=n;i;i--)
    {
        for(int j=1;j<i;j++)
        {
            if(a[i]<a[j])
            ans.push_back({a[j],a[i]});
        }
    }
    for(int i=1;i<=n;i++)
    {
        stack<pii>st;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]<a[i])break;
            st.push({a[j],a[i]});
            ans.push_back({a[j],a[i]});
        }
        while(st.size())
        {
            auto x=st.top();
            swap(x.first,x.second);
            ans.push_back(x);
            st.pop();
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.first<<" "<<x.second<<endl;
}
signed main()
{

    sol();
return 0;
}


Submission (verdict: Wrong answer on test 7):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    vector<pii>ans;
    vector<bool>vis(n+1,0);
    for(int i=n;i;i--)
    {
        vis[a[i]]=1;
        for(int j=a[i]+1;j<=n;j++)
        {
            if(vis[j])continue;
            ans.push_back({j,a[i]});
        }
    }
    for(int i=1;i<=n;i++)
    {
        stack<pii>st;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]<a[i])break;
            st.push({a[j],a[i]});
            ans.push_back({a[j],a[i]});
        }
        while(st.size())
        {
            auto x=st.top();
            swap(x.first,x.second);
            ans.push_back(x);
            st.pop();
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.first<<" "<<x.second<<endl;
}
signed main()
{

    sol();
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    vector<pii>ans;
    vector<bool>vis(n+1,0);
    for(int i=n;i;i--)
    {
        vis[a[i]]=1;
        for(int j=a[i]+1;j<=n;j++)
        {
            if(vis[j])continue;
            ans.push_back({j,a[i]});
        }
    }
    for(int i=1;i<=n;i++)
    {
        stack<pii>st;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]<a[i])break;
            st.push({a[j],a[i]});
            ans.push_back({a[j],a[i]});
        }
        while(st.size())
        {
            auto x=st.top();
            swap(x.first,x.second);
            ans.push_back(x);
            st.pop();
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.first<<" "<<x.second<<endl;
}
signed main()
{

    sol();
return 0;
}


Submission (verdict: Accepted):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    vector<int>pos(n+1,0);
    vector<pii>ans;
    for(int i=1;i<=n;i++)pos[a[i]]=i;
    vector<int>num(n);
    iota(num.begin(),num.end(),1);
    sort(num.begin(),num.end(),[&](const int a,const int b)
         {
             return pos[a]<pos[b];
         });
    vector<int>no(n+1,0);///当前状态 在当前位置的车得编号
    iota(no.begin()+1,no.end(),1);
    vector<int>curpos=no;///每车在当前的位置
    int ub=n;
    for(int i:num)
    {
        for(int j=curpos[i]+1;j<=n;j++)///先跑到目前为止能跑得最远得地方
        {
            ans.push_back({no[j],no[j-1]});
            swap(no[j],no[j-1]);
            swap(curpos[no[j]],curpos[no[j-1]]);
        }
        while(curpos[i]>pos[i])///ub是当前位置
        {
            ///ub->ub-1
            ans.push_back({no[curpos[i]],no[curpos[i]-1]});
            swap(no[curpos[i]],no[curpos[i]-1]);
            swap(curpos[no[curpos[i]]],curpos[no[curpos[i]-1]]);
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.first<<" "<<x.second<<endl;
}
signed main()
{

    sol();
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    for(int i=n;i;i--)
    {
        for(int j=1;j<i;j++)
        {
            if(a[i]<a[j])
            {
                cout<<a[j]<<" "<<a[i]<<endl;
            }
            else
            {
                cout<<a[j]<<" "<<a[i]<<endl;
                cout<<a[i]<<" "<<a[j]<<endl;
            }
        }
    }
}
signed main()
{

    sol();
return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    for(int i=n;i;i--)
    {
        for(int j=1;j<i;j++)
        {
            if(a[i]<a[j])
            {
                cout<<a[j]<<" "<<a[i]<<endl;
            }
            else
            {
                cout<<a[j]<<" "<<a[i]<<endl;
                cout<<a[i]<<" "<<a[j]<<endl;
            }
        }
    }
}
signed main()
{

    sol();
return 0;
}


Submission (verdict: Wrong answer on test 1):
#include"bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
void sol()
{
    int n;
    cin>>n;
    vector<int>a(n+1,0);
    for(int i=1;i<=n;cin>>a[i++]);
    vector<pii>ans;
    for(int i=n;i;i--)
    {
        for(int j=1;j<i;j++)
        {
            ans.push_back({a[j],a[i]});
            if(a[i]>=a[j])
            {
                ans.push_back({a[i],a[j]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans)
        cout<<x.first<<" "<<x.second<<endl;
}
signed main()
{

    sol();
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
long long a[55];
long long  sum = 0;
long long ans = 0;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        sum = 0,ans = 0;
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
            sum += a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                reverse(a,a+n);//1
                ans = 0;
                for(int i=0;i<n;i++)
                {
                    ans += a[i];
                }
                sum = max(ans,abs(sum));
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
long long a[55];
long long  sum = 0;
long long ans = 0;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        sum = 0,ans = 0;
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
            sum += a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                ans = 0 ;
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}