1 solutions

  • 0
    @ 2022-3-7 11:20:22

    比火车那题简单

    #include<iostream>
    #include<stack>
    using namespace std;
    const int N=1e7+7;
    int n,c[N],t=1;
    stack<int>s;
    
    int main(){
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>c[i];
    		cout<<"A";
    		s.push(i);
    		while(!s.empty()&&s.top()==c[t]&&t<=i){
    			cout<<"B";
    			s.pop();
    			t++;
    		}
    	}
    	while(!s.empty()){
    		s.pop();
    		cout<<"B";
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    1127
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    4
    Tags
    # Submissions
    43
    Accepted
    22
    Uploaded By