记录编号 323219 评测结果 AAAAAAAAAA
题目名称 1697.人工湖 最终得分 100
用户昵称 AntiLeaf 是否通过 通过
代码语言 C++ 运行时间 0.114 s
提交时间 2016-10-16 07:42:54 内存使用 0.60 MiB
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<algorithm>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
namespace mine{
	template<class T>inline void readint(T &__x){
		static int __c;
		static bool __neg;
		__x=0;
		__neg=false;
		do __c=getchar();while(__c==' '||__c=='\n'||__c=='\r'||__c=='\t');
		if(__c=='-'){
			__neg=true;
			__c=getchar();
		}
		for(;__c>='0'&&__c<='9';__c=getchar())__x=__x*10+(__c^48);
		if(__neg)__x=-__x;
	}
	template<class T>inline void putint(T __x){
		static int __a[40],__i,__j;
		static bool __neg;
		__neg=__x<0;
		if(__neg)__x=-__x;
		__i=0;
		do{
			__a[__i++]=__x%(T)10^(T)48;
			__x/=10;
		}while(__x);
		if(__neg)putchar('-');
		for(__j=__i-1;__j^-1;__j--)putchar(__a[__j]);
	}
}
using namespace mine;
const int maxn=100010;
void add(int,int);
int query(int);
int n,m,c[maxn],d,x,y;
int main(){
#define MINE
#ifdef MINE
	freopen("lakee.in","r",stdin);
	freopen("lakee.out","w",stdout);
#endif
	readint(n);
	readint(m);
	while(m--){
		readint(d);
		readint(x);
		readint(y);
		if(x>y)swap(x,y);
		if(d){
			if(query(y)-query(x)&&query(x)+query(n)-query(y))printf("NO\n");
			else printf("YES\n");
		}
		else{
			if(query(y)-query(y-1))add(y,-1);
			else add(y,1);
		}
	}
#ifndef MINE
	printf("\n-------------------------DONE-------------------------\n");
	for(;;);
#endif
    return 0;
}
void add(int x,int d){
	while(x<=n){
		c[x]+=d;
		x+=lowbit(x);
	}
}
int query(int x){
	int ans=0;
	while(x){
		ans+=c[x];
		x-=lowbit(x);
	}
	return ans;
}