1 solutions

  • 1
    @ 2024-11-16 21:28:32

    其实很简单

    using namespace std;
    int b[110];
    int main(){
        int n;
        scanf("%d",&n);
        stack<int>c;
        for(int i = 1;i<=n;i++)scanf("%d",&b[i]);
        for(int i = 1,cur = 1;i<=n;i++){
            while(cur<=b[i]){
                c.push(cur);
                printf("A");
                cur++;
            }
            if(c.top() == b[i]){
                c.pop();
                printf("B");
            }
        }
        while(!c.empty()){
            printf("B");
            c.pop();
        }
        return 0;
    }
    
    
    • 1

    Information

    ID
    639
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    7
    Accepted
    4
    Uploaded By