zoukankan      html  css  js  c++  java
  • NOIP2018 全国热身赛 第二场 (不开放)

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

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

    #include <iostream>
    #include <set>
    #include <cstdio>
    #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 <int>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<int>::iterator i=s.begin();i!=s.end();i++) cout<<*i-tot<<' ';cout<<endl;
    	return 0;
    }
    
    
  • 相关阅读:
    webkit之滚动条美化
    意想不到的javascript
    html5 的存储
    javascript 中的number
    javascript 模板
    关于ajax的跨域
    一个菜鸟眼中的前端
    【转】python
    [转]修改python默认的编码方式
    搞科研
  • 原文地址:https://www.cnblogs.com/tpgzy/p/9825136.html
Copyright © 2011-2022 走看看