666

6  •  11个月前


#include <bits/stdc++.h>
#include <stack>
#include <queue>
using namespace std;

int main() {
	stack<int>q1;
	stack<int>q2;
	queue<int>q3;
	int n, m = 1, a, b, c;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		q3.push(i);
	}
	for (int i = 1; i > 0; i++) {
		cin >> a >> b;
		if (a == 1) {
			c += b;
			for (int j = 0; j < b; j++) {
				q1.push(q3.front());
				q3.pop();
			}
		} else if (a == 2) {
			for (int j = 0; j < b; j++) {
				q2.push(q1.top() );
				q1.pop() ;
			}
		}
		if (q1.empty() && q2.size() == n) {
			break;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << q2.top() << endl;
		q2.pop() ;
	}
	return 0;
}

评论:

请先登录,才能进行评论