比赛 2026.9.12 评测结果 AAAAAAAAAA
题目名称 画线 最终得分 100
用户昵称 赵飞羽 运行时间 0.638 s
代码语言 C++ 内存使用 7.96 MiB
提交时间 2026-09-12 09:23:28
显示代码纯文本
#include <bits/stdc++.h>
#define int long long
using namespace std;

constexpr int N = 1000010;
int n, q, c[N];
int lowbit(int x) {return (x&(-x));}
void update(int x, int v) {
	while (x <= n) {
		c[x] += v;
		x += lowbit(x);
	}
}
int query(int x) {
	int cnt = 0;
	while (x) {
		cnt += c[x];
		x -= lowbit(x);
	}
	return cnt;
}
mt19937 rng(time(0));

signed main() {
	freopen("circle.in", "r", stdin);
	freopen("circle.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> q;
	while (q--) {
		int x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		if (query(x) == query(y)) {
			cout << "Yes\n";
			int z = rng();
			update(x, z);
			update(y + 1, -z);
		} else cout << "No\n";
	}
	return 0;
}