NO,3小时
2024-02-23 11:17:05
发布于:北京
#include<bits/stdc++.h>
using namespace std;
int main(){
	queue<string> vip;
    queue<string> nvip;
    int n;
    string h,m="0";
    cin>>n;
    while(n--){
        cin>>h;
        if(m=="0"&&h!="end"){
            m=h;
        }else{
            if(h[0]=='V'){
            	vip.push(h);
            }else if(h[0]=='N'){
                nvip.push(h);
            }
            if(h=="end"){
                if(!vip.empty()){
                    m=vip.front();
                    vip.pop();
                }
                else if(!nvip.empty()){
                    m=nvip.front();
                    nvip.pop();
                }else{
                    m="0";
                }
            }
		}
        
    }
    while(!vip.empty()||!nvip.empty()){
        if(!vip.empty()){
            cout<<vip.front()<<" ";
            vip.pop();
        }else{
            cout<<nvip.front()<<" ";
            nvip.pop();
        }
    }
	return 0;
}
这里空空如也






有帮助,赞一个