NOIP模拟测试16

今天也没有什么干劲,明天再开始努力吧 OwO

Problem A: Blue

看数据范围必定贪心啊!

今天也没有什么干劲,明天再开始努力吧 OwO

懒得想了,建图流就完事了。

zzz边权写错了,得到了20分的好成绩。

正解就是个十分弱智的贪心,一只蛤蛤在能力范围内跳得越远越好。

 1 #include <bits/stdc++.h>
 2 
 3 int n, m, d, l, t, a[10000005];
 4 
 5 inline int R() {
 6     int a = 0; char c = getchar();
 7     while (!isdigit(c)) c = getchar();
 8     while (isdigit(c)) a = a * 10 + c - '0', c = getchar();
 9     return a;
10 }
11 
12 signed main() {
13     t = R();
14     while (t--) {
15         n = R(), m = R(), d = R(), l = R();
16         for (int i = 1; i <= n; i++) a[i] = R();
17         a[0] = 0, a[n + 1] = l;
18         if (d >= l) {
19             puts("Excited");
20             continue;
21         }
22         int ans = m, now = 0;
23         for (int i = 0; i <= n; i++) {
24             while (now != n + 1 && a[now + 1] - a[i] <= d) now++;
25             if (now == n + 1) break;
26             ans = std::min(ans, now - i);
27         }
28         if (ans == m) puts("Excited");
29         else printf("%d\n", ans);
30     }
31     return 0;
32 }
Problem A

Problem B: Weed

smoke weed every day我一看,草,这题学长讲过啊!写爆!

看着上传不能的pushup()我调了2h。拖死整个考试,喜提全场倒一一个。

把最重要的calc函数忘了,除了这玩意这题还有啥啊Orz

每个节点记一下坷拉和sum,需要减掉的clr和加坷拉数siz。线段树维护操作序列。

上传时分为右儿子把左儿子删完,右儿子不用删和删不完三种,前两种好处理,第三种要另写一个clac()函数去删除。

clac()自己模拟一下就能推出来了但我考场就是写不出来

 

 1 #include <bits/stdc++.h>
 2 
 3 const int N = 4e5;
 4 int n, q;
 5 struct Ask {int op, val;} ak[N];
 6 
 7 class SegTree {
 8 private:
 9     struct Node {
10         int l, r, siz, clr, sum;
11     } t[N << 2];
12     int _calc(int p, int rm) {
13         if (t[p << 1 | 1].siz == rm)
14             return t[p].sum - t[p << 1 | 1].sum;
15         else if (t[p << 1 | 1].siz > rm)
16             return t[p].sum - t[p << 1 | 1].sum + _calc(p << 1 | 1, rm);
17         else 
18             return _calc(p << 1, rm - t[p << 1 | 1].siz + t[p << 1 | 1].clr);
19     }
20     void _pushup(int p) {
21         if (t[p << 1 | 1].clr >= t[p << 1].siz) {
22             t[p].clr = t[p << 1].clr + t[p << 1 | 1].clr - t[p << 1].siz;
23             t[p].siz = t[p << 1 | 1].siz;
24             t[p].sum = t[p << 1 | 1].sum;
25         } else if (!t[p << 1 | 1].clr) {
26             t[p].clr = t[p << 1].clr + t[p << 1 | 1].clr;
27             t[p].siz = t[p << 1].siz + t[p << 1 | 1].siz;
28             t[p].sum = t[p << 1].sum + t[p << 1 | 1].sum;
29         } else {
30             t[p].clr = t[p << 1].clr;
31             t[p].siz = t[p << 1].siz + t[p << 1 | 1].siz - t[p << 1 | 1].clr;
32             t[p].sum = t[p << 1 | 1].sum + _calc(p << 1, t[p << 1 | 1].clr);
33         }
34     }
35     void _build(int p, int l, int r) {
36         t[p].l = l, t[p].r = r, t[p].siz = t[p].clr = t[p].sum = 0;
37         if (l == r) {
38             if (ak[l].op == 0) t[p].sum = ak[l].val;
39             else t[p].clr = ak[l].val;
40             t[p].siz = t[p].sum ? 1 : 0;
41             return;
42         }
43         int mid = (l + r) >> 1;
44         _build(p << 1, l, mid), _build(p << 1 | 1, mid + 1, r);
45         _pushup(p);
46     }
47     void _change(int p, int x, int op, int v) {
48         if (t[p].l == t[p].r) {
49             t[p].siz = t[p].clr = t[p].sum = 0;
50             if (op) t[p].clr = v;
51             else t[p].sum = v, t[p].siz = 1;
52             return;
53         }
54         int mid = (t[p].l + t[p].r) >> 1;
55         if (x <= mid) _change(p << 1, x, op, v);
56         if (x > mid) _change(p << 1 | 1, x, op, v);
57         _pushup(p);
58     }
59 public:
60     SegTree() {
61         _build(1, 1, n);
62     }
63     void change(int op, int x, int v) {
64         _change(1, x, op, v);
65     }
66     int query() {
67         return t[1].sum;
68     }
69 };
70 
71 inline int read() {
72     int a = 0; char c = getchar();
73     while (!isdigit(c)) c = getchar();
74     while (isdigit(c)) a = a * 10 + c - '0', c = getchar();
75     return a;
76 }
77 
78 signed main() {
79     n = read(), q = read();
80     for (int i = 1; i <= n; i++)
81         ak[i].op = read(), ak[i].val = read();
82     static SegTree *Gekoo = new SegTree();
83     for (int i = 1; i <= q; i++) {
84         int c = read(), k = read(), v = read();
85         Gekoo->change(k, c, v);
86         printf("%d\n", Gekoo->query());
87     }
88     return 0;
89 }
Problem B

 

Problem C: Drink

这题暴力都很恶心,写个rotate()函数写了我半小时,最后时间不够没写完。

正解不会,留坑。

其他的东西

这次考试是2019年我拿的第一个倒一,抛开马上回太原的欣喜难平,这次我的考试策略就是一坨shit。

T1贪心很容易就能想出来,但就因为沉迷摸鱼懒得想打了网络流骗分。

至于T2,某人码力啥水平某人自己心里还没点B数吗(逃,何必去刚线段树的正解,先把暴力打了啊喂

T3,时间不够了QAQ,要是多点时间把那个rotate()写完还是能得到大众分的。。。

希望以后少些SB操作,考试的时候聪明些。

希望这会是我OI生涯的最后一个倒一。

转载于:https://www.cnblogs.com/gekoo/p/11331691.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值