- Time: 2016-04-09-23:29:47 Saturday
- Title Number: [2016-04-09][codeforces][660][b][seating on Bus]
- Main topic: Seated in a specified order, out of the seat in a specified order, asking the order of the last out seat
- Analysis: Direct 4 queue simulations once again
#include<cstdio>
#include<queue>
using namespace std;
queue<int> q[4];
int main(){
int n,m;
scanf("%d%d",&n,&m);
int i = 1;
for(;i <= 2*n && i <= m;++i)
q[i&1].push(i);
for(;i<=4*n && i<= m;++i)
q[(i&1) + 2].push(i);
while (! q [ 0 . empty () | | ! q [ 1 . empty () | |! q [ 3 . empty () | |! q [ 2 . empty ()) {
if(!q[3].empty()){
printf("%d ",q[3].front());q[3].pop();
}
if(!q[1].empty()){
printf("%d ",q[1].front());q[1].pop();
}
if(!q[2].empty()){
printf("%d ",q[2].front());q[2].pop();
}
if(!q[0].empty()){
printf("%d ",q[0].front());q[0].pop();
}
}
return 0;
}
From for notes (Wiz)
[2016-04-09] [Codeforces] [660] B [Seating on Bus]