Solutions - NOISG 2021 重现赛

最烂的一把。\(85+0+20+100+18\) 什么实力。

T1

主观难度:【1+】

就是一个简单分类讨论,可惜场上糖了。

#include <bits/stdc++.h>
#define llong long long
#define double long double
#define N 300005
using namespace std;

#define bs (1<<20)
char buf[bs], *p1, *p2;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,bs,stdin),p1==p2)?EOF:*p1++)
template<typename T>
inline void read(T& x){
    x = 0; int w = 1;
    char ch = gc();
    while(ch < '0' || ch > '9'){
        if(ch == '-') w = -w;
        ch = gc();
    }
    while(ch >= '0' && ch <= '9')
        x = (x<<3)+(x<<1)+(ch^48), ch = gc();
    x *= w;
}
template<typename T, typename ...Args>
inline void read(T& x, Args& ...y){
    return read(x), read(y...);
}

constexpr double eps = 1e-12;

int n;
int a[N], b[N];
double minn, maxn;

int main(){
    read(n);
    for(int i = 1; i <= n; ++i) read(a[i]);
    for(int i = 1; i <= n; ++i) read(b[i]);
    minn = 0, maxn = INFINITY;
    for(int i = 1; i < n; ++i){
        if(b[i+1] == b[i] && a[i+1] >= a[i]){
            puts("NO");
            return 0;
        }
        else if(b[i+1] > b[i]) maxn = min(maxn, -(double)1.0*(a[i+1]-a[i])/(b[i+1]-b[i]));
        else if(b[i+1] < b[i]) minn = max(minn, -(double)1.0*(a[i+1]-a[i])/(b[i+1]-b[i]));
    }
    puts((maxn-minn < eps) ? "NO" : "YES");
    return 0;
}

T2

主观难度:【3】

这不是 T2 来着。为什么会变成这样呢。


较明显地,我们需要在打 tag 时尽量存储子树下还有多少个叶子,但是我们发现似乎存不下。

我们发现我们其实并不需要知道具体有多少个叶子没有被访问,只需要知道是否有叶子没有被访问即可。于是我们可以存成 \(\max \{ l-siz, 0 \}\),其中 \(siz\) 是还没有被访问过的叶子数量。

但是我们并不知道一个标记为 \(0\) 的节点是真的有一堆未访问的叶子还是单纯

算了没时间写了等一会再写吧

posted @ 2026-03-10 10:40  Hootime  阅读(2)  评论(0)    收藏  举报