| 比赛 |
2026.9.12 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
画线 |
最终得分 |
100 |
| 用户昵称 |
Ruyi |
运行时间 |
1.771 s |
| 代码语言 |
C++ |
内存使用 |
43.50 MiB |
| 提交时间 |
2026-09-12 11:13:56 |
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
#define N 1000001
#define mod 998244353
using namespace std;
ll n,q,x,y,v[N]={1};
struct tree{ll l,r,ans,lazy;}t[4*N];
ll read(){
ll x=0,f=1;
char c=' ';
while(c>'9'||c<'0'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=x*10+(c-'0');
c=getchar();
}
return x*f;
}
void write(ll x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9) write(x/10);
putchar(x%10+'0');
return ;
}
void pushdown(ll p){
if(t[p].lazy==0) return ;
t[p*2].lazy+=t[p].lazy;
t[p*2+1].lazy+=t[p].lazy;
t[p*2].ans+=t[p].lazy;
t[p*2+1].ans+=t[p].lazy;
t[p].lazy=0;
return ;
}
void build(ll p,ll l,ll r){
t[p].l=l;
t[p].r=r;
if(l==r) return ;
ll mid=(l+r)/2;
build(p*2,l,mid);
build(p*2+1,mid+1,r);
return ;
}
void upd(ll p,ll l,ll r,ll val){
if(l<=t[p].l&&t[p].r<=r){
t[p].ans+=val;
t[p].lazy+=val;
return ;
}
pushdown(p);
ll mid=(t[p].l+t[p].r)/2;
if(l<=mid) upd(p*2,l,r,val);
if(r>mid) upd(p*2+1,l,r,val);
return ;
}
ll query(ll p,ll x){
if(t[p].l==t[p].r) return t[p].ans;
ll mid=(t[p].l+t[p].r)/2;
pushdown(p);
if(x<=mid) return query(p*2,x);
return query(p*2+1,x);
}
int main(){
freopen("circle.in","r",stdin);
freopen("circle.out","w",stdout);
n=read();
q=read();
build(1,1,n);
for(int i=1;i<=q;i++) v[i]=v[i-1]*2%mod;
while(q--){
x=read();
y=read();
if(x>y) swap(x,y);
if(query(1,x)!=query(1,y)){
putchar('N');
putchar('o');
putchar('\n');
}else{
putchar('Y');
putchar('e');
putchar('s');
putchar('\n');
upd(1,x,y,v[q]);
}
}
return 0;
}