20分求调
  • 板块P9518 queue
  • 楼主Yxy7952
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/6/22 21:02
  • 上次更新2024/6/23 07:46:29
查看原帖
20分求调
936717
Yxy7952楼主2024/6/22 21:02
#include<bits/stdc++.h>
using namespace std;
int n,l=1,r=0,d=1;
string sra,srb,a[100005];
bool jr(string x){
	for(int i=1;i<=r;i++){
		if(a[i]==x){
			return 1;
		}
	}
	return 0;
}
bool lk(string x){
	for(int i=3;i<=r;i++){
		if(a[i]==x){
			return 1;
		}
	}
	return 0;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>sra;
		if(sra=="start"){
			if(r-l+1>=1){
				cout<<
			}
			if(d==1){
				d=-1;
			}
			else{
				r++;
				a[r]=a[l];
				l++;
				r++;
				a[r]=a[l];
				l++;
			}
		}
		if(sra=="arrive"){
			cin>>srb;
			if(jr(srb)){
				cout<<"Error\n";
			}
			else{
				r++;
				a[r]=srb;
				cout<<"OK\n";
			}
		}
		if(sra=="leave"){
			cin>>srb;
			if(lk(srb)&&a[1]!=srb&&a[2]!=srb){
				l++;
				cout<<"OK\n";
			}
			else{
				cout<<"Error\n";
			}
		}
	}
	return 0;
}

2024/6/22 21:02
加载中...