Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- vector<int> V;
- vector<bool> Q;
- bool room[20];
- int num[100020];
- int ind[100020];
- bool check;
- bool q[100020];
- int in;
- int cur;
- int main()
- {
- int n,m;
- scanf("%d%d",&n,&m);
- int a,b;
- int n2=n*2;
- while(n2--){
- scanf("%d%d",&a,&b);
- if(a==1){
- check=false;
- for(int i=1;i<=m;i++){
- if(!room[i]){
- room[i]=true;
- num[b]=i;
- check=true;
- i=m+1;
- }
- }
- if(!check){
- V.push_back(b);
- }
- }
- else if(a==2){
- if(num[b]!=0){
- room[num[b]]=false;
- if(!V.empty()){
- while(!V.empty() && q[V.front()]) V.erase(V.begin());
- if(!V.empty()){
- room[num[b]]=true;
- num[V.front()]=num[b];
- V.erase(V.begin());
- }
- }
- }
- else{
- q[b]=true;
- }
- }
- }
- for(int i=1;i<=n;i++) printf("%d\n",num[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement