NOIP2018 全国热身赛 第二场 (不开放)


NOIP2018 全国热身赛 第二场 (不开放)

题目链接:http://noi.ac/contest/26/problem/60
一道蛮有趣的题目.
然后比赛傻逼了.
即将做出来的时候去做别的题了.
100分没了
可以想到的是.
2操作时,是将每个球的位置 \(-1\) ,然后把最左边的球放到 \(P-1\) 处。
之后记录一个\(-1\) 次数保证相对位置不变.
然后用set维护一下.(map + queue也可以)

#include 
#include 
#include 
#define rep(i,x,p) for(int i = x;i <= p;++ i)
#define sep(i,x,p) for(int i = x;i >= p;-- i)
#define gc getchar()
using namespace std;

set s;

inline int read() {
	int x = 0,f = 1;char c = gc;
	while(c < '0' || c > '9') {if(c == '-')f = -1;c = gc;}
	while(c >= '0' && c <= '9') {x = x * 10 + c - '0';c = gc;}
	return x * f;
}

int main() {
	int n,m,P,x,tot = 0;
	n = read();m = read();P = read();
	rep(i,1,n) {x = read();s.insert(x);}
	while(m --) {
		int type = read();
		if(type == 1) {
			x = read();
			s.insert(x + tot);
		}else {
			tot ++;
			s.erase(s.begin());
			s.insert(P + tot - 1);
		}
	}
	for (set::iterator i=s.begin();i!=s.end();i++) cout<<*i-tot<<' ';cout<
STL