比赛 2026.9.12 评测结果 AAAAAAAAAA
题目名称 画线 最终得分 100
用户昵称 终焉折枝 运行时间 1.576 s
代码语言 C++ 内存使用 32.54 MiB
提交时间 2026-09-12 10:29:55
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define lc u << 1
#define rc u << 1 | 1
mt19937_64 rnd;
ull val;
 
inline ull shift(ull x){
    x ^= val;
    x ^= (x << 11);
    x ^= (x >> 7);
    x ^= (x << 13);
    return x + 114514191981083ull;
}
int n, q;
ull tot = 0;

const int N = 1e6 + 5;
struct node{
    int l, r;
    ull v;
    ull tag;
}t[N << 2];

inline void down(int u){
    if(t[u].tag){
        t[lc].v += t[u].tag;
        t[rc].v += t[u].tag; 
        t[lc].tag += t[u].tag;
        t[rc].tag += t[u].tag;
        t[u].tag = 0;
    }
}

inline void build(int u, int l, int r){
    t[u] = {l, r, (ull)0, (ull)0};
    if(l == r) return;
    int mid = (l + r) >> 1;
    build(lc, l, mid);
    build(rc, mid + 1, r);
}

inline void upd(int u, int l, int r, int k){
    if(l <= t[u].l && t[u].r <= r){
        t[u].tag += k;
        t[u].v += k;
        return;
    }
    down(u);
    int mid = (t[u].l + t[u].r) >> 1;
    if(l <= mid) upd(lc, l, r, k);
    if(r > mid) upd(rc, l, r, k);
}

inline ull qry(int u, int pos){
    if(t[u].l == t[u].r){
        return t[u].v;
    }
    down(u);
    int mid = (t[u].l + t[u].r) >> 1;
    if(pos <= mid) return qry(lc, pos);
    else return qry(rc, pos);
}

int main(){
    freopen("circle.in", "r", stdin);
    freopen("circle.out", "w", stdout);
    rnd.seed(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0) -> ios::sync_with_stdio(0);
    val = rnd();
    cin >> n >> q;
    build(1, 1, n);
    for(int i = 1;i <= q;i ++){
        int l, r; cin >> l >> r;
        ull fx = qry(1, l), fy = qry(1, r);
        if(fx != fy){
            cout << "No\n";
        }
        else{
            tot ++;
            cout << "Yes\n";
            if(l > r){
                upd(1, r, n, shift(tot));
                upd(1, 1, l, shift(tot));
            }
            else{
                upd(1, l, r, shift(tot));
            }
        }
    }
    return 0;
}