| 比赛 |
2026.9.12 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
画线 |
最终得分 |
100 |
| 用户昵称 |
ChenBp |
运行时间 |
1.548 s |
| 代码语言 |
C++ |
内存使用 |
24.05 MiB |
| 提交时间 |
2026-09-12 09:44:12 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstring>
using namespace std;
const int N=1e6+6,INF=0x3f3f3f3f;
//struct node{
// int x,y;
// bool operator<(const node& o)const &{
// return x<o.x;
// }
// node(){x=y=0;}
// node(int _x,int _y){x=_x,y=_y;}
//};
//set<node>s;
const int tN=4*N;
int mn[tN],mx[tN];
#define mid ((l+r)/2)
#define lc (u*2)
#define rc (u*2+1)
void update(int u,int l,int r,int x,int v){
if(l==r){
mn[u]=mx[u]=v;
return;
}
if(x<=mid) update(lc,l,mid,x,v);
else update(rc,mid+1,r,x,v);
mn[u]=min(mn[lc],mn[rc]);
mx[u]=max(mx[lc],mx[rc]);
}
struct RES{
int mn,mx;
RES(){mn=mx=0;}
RES(int n,int x){mn=n,mx=x;}
RES operator+(const RES& o){
return RES(min(mn,o.mn),max(mx,o.mx));
}
};
RES query(int u,int l,int r,int xl,int xr){
if(xl<=l&&r<=xr){
return RES(mn[u],mx[u]);
}
if(xr<=mid) return query(lc,l,mid,xl,xr);
if(mid+1<=xl) return query(rc,mid+1,r,xl,xr);
return query(lc,l,mid,xl,xr)+query(rc,mid+1,r,xl,xr);
}
bool hav[N];
int n,q;
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;
memset(mn,0x3f,sizeof(mn));
while(q--){
int x,y;
cin>>x>>y;
if(x>y) swap(x,y);
bool ok=1;
if(hav[x]||hav[y]) ok=0;
RES res=query(1,1,n,x,y);
// cout<<res.mn<<" "<<res.mn<<"\n";
if(res.mn<x||res.mx>y) ok=0;
if(ok==0){
cout<<"No\n";
}else{
cout<<"Yes\n";
hav[x]=hav[y]=1;
update(1,1,n,x,y);
update(1,1,n,y,x);
}
}
return 0;
}