| 比赛 |
2026.9.12 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
画线 |
最终得分 |
100 |
| 用户昵称 |
杨蕙宇 |
运行时间 |
1.443 s |
| 代码语言 |
C++ |
内存使用 |
13.39 MiB |
| 提交时间 |
2026-09-12 11:22:47 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
set<int>st;
int n,q;
int l[N],r[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
freopen("circle.in","r",stdin);
freopen("circle.out","w",stdout);
cin>>n>>q;
st.insert(0);
st.insert(n+1);
l[0]=0;
l[n+1]=0;
r[0]=n+1;
r[n+1]=n+1;
while(q--){
int x,y;
cin>>x>>y;
if(x>y)swap(x,y);
auto it=st.lower_bound(x);
bool f=0;
while(*it<=y){
int ll=l[*it],rr=r[*it];
if((ll>x&&ll<y&&rr>y)||(rr>x&&rr<y&&ll<x)){
cout<<"No\n";
f=1;
break;
}
it=st.find(rr);
if(*it!=n+1)it++;
}
if(f)continue;
cout<<"Yes\n";
st.insert(x);
st.insert(y);
l[x]=x,l[y]=x,r[x]=y,r[y]=y;
}
return 0;
}