求助离谱的RE
  • 板块学术版
  • 楼主SJZ2010
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/7/9 18:03
  • 上次更新2023/11/3 10:53:09
查看原帖
求助离谱的RE
809729
SJZ2010楼主2023/7/9 18:03

P9452 月赛B题

这是什么原因导致的RE?

Runtime Error.
Received signal 6: Aborted / IOT trap.

代码

#include<bits/stdc++.h>
using namespace std;
string ans[4000000];
stack<int> A,B,C;
long long n,Cnt;
long long a[40005],b[40005];
bool find(stack<int> stk,int x){
    while(!stk.empty()){
        if(stk.top()==x)
            return true;
        stk.pop();
    }
    return false;
}
int main(){
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b+1,b+n+1,greater<int>());
    for(int i=n;i>=1;i--)
        A.push(a[i]);
    for(int i=1;i<=n;i++){
        if(find(A,b[i])){
            while(A.top()!=b[i]){
                ans[++Cnt]="A B";
                B.push(A.top());
                A.pop();
            }
            ans[++Cnt]="A C";
            A.pop();
        }else{
            while(B.top()!=b[i]){
                ans[++Cnt]="B A";
                A.push(B.top());
                B.pop();
            }
            ans[++Cnt]="B C";
            B.pop();
        }
    }
    cout<<Cnt<<endl;
    for(int i=1;i<=Cnt;i++)
        cout<<ans[i]<<endl;
    return 0;
}
2023/7/9 18:03
加载中...