| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 65418 | 曾浩然 | [在线测评解答教程] A+B Problem | C++ | Runtime Error | 2 MS | 272 KB | 841 | 2024-01-25 15:11:48 |
#include<bits/stdc++.h> using namespace std; int main(){ int a_in[100],a_out[100],a_move[100]; int n; cin>>n; stack<int> stk; for(int i=0;i<n;i++){ cin>>a_in[i]; } for(int i=0;i<n;i++){ cin>>a_out[i]; } int i=0,j=0,k=0; while(i<n){ if(a_in[i]==a_out[j]){ a_move[k++]=1; a_move[k++]=0; i++,j++; }else{ a_move[k++]=1; stk.push(a_in[i]); i++; } } while(j<n){ if(stk.empty()){ cout<<"No"<<endl; cout<<"FINISH"<<endl; return 0; } if(a_out[j]==stk.top()){ a_move[k++]=0; stk.pop(); j++; }else{ cout<<"No"<<endl; cout<<"FINISH"<<endl; return 0; } } cout<<"Yes"<<endl; for(int i=0;i<k;i++){ if(a_move[i]==1){ cout<<"in"<<endl; }else{ cout<<"out"<<endl; } } cout<<"FINISH"<<endl; return 0; }
*** stack smashing detected ***: ./Main terminated