include
include
using namespace std;
int main()
{
char cmd;
int people=0,no=0,elem=0,ansno=0;//people为国民人数 no为执行命令的数量 ansno为需要输出样例答案的数量
int casek=1;
while(cin>>people>>no)
{
int Queue[3000]={0};
int front=0,rear=0;
int counter=0;
if(people==0&&no==0){break;}
cout<<”Case “<<casek<<”:”<<endl;
for(int i=0;i<min(people,no);i++)
{
Queue[1000+i]=i+1;
rear=1001+i;
}//rear指向实际队列队尾元素的下一个
front=1000;
for(int i=0;i<no;i++)
{
cin>>cmd;
if(cmd=='N')//如果N则从队头开始遍历找到第一个不为0的元素并存储答案然后将其移到队尾
{
while(Queue[front]==0){front++;}
cout<<Queue[front]<<endl;
Queue[rear++]=Queue[front];
Queue[front++]=0;
}
else if(cmd=='E')
{
cin>>elem;
for (int j=front;j<rear;j++)
{
if(Queue[j]==elem) Queue[j]=0;
}
Queue[--front]=elem;
}
}
casek++;
}
}
目前帮大佬改正了错误,但任然是wrong answer
代码贴上来,有大佬能看看么。哭哭
include
include
include
using namespace std;
int main()
{
int j=0;
int i=0;
for(int k=1;k<=ansno;k++)
{
}