| 比赛 |
2026.9.12 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
画线 |
最终得分 |
100 |
| 用户昵称 |
彭欣越 |
运行时间 |
0.765 s |
| 代码语言 |
C++ |
内存使用 |
7.97 MiB |
| 提交时间 |
2026-09-12 12:25:04 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N=2000010;
int n,q,a[N];
ll c[N];
ll lowbit (ll x) {
return x&-x;
}
void add (int x,ll v) {
while (x<=n) {
c[x]+=v;
x+=lowbit(x);
}
}
ll query (int x) {
ll sum=0;
while (x) {
sum+=c[x];
x-=lowbit(x);
}
return sum;
}
int 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;
int cnt=1;
while (q--) {
int l,r;
cin >> l >> r;
if (query(l)==query(r)) {
cout << "Yes" <<"\n";
add(l,cnt);
add(r,-cnt);
cnt*=cnt+1;
}else{
cout << "No" <<"\n";
}
}
return 0;
}