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;
}

转载于:https://www.cnblogs.com/tpgzy/p/9825136.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值