#include <bits/stdc++.h> #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) #define ms(s,x) memset(s,x,sizeof(s)) #define ls rt<<1 #define rs rt<<1|1 #define pb push_back #define mp make_pair #define inf 0x3f3f3f3f typedef long long ll; using namespace std; const double PI = acos(-1.0); const double eps = 1e-8; const int N = 1e5+5; const ll mod = 1e9+7; template <class T> inline void read(T &res){ char c;T f=1; while((c=getchar())<'0'||c>'9')if(c=='-')f=-1;res=c-'0'; while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=f; } set <int> st; set <int>::iterator it1, it2; int main() { int m, k, x; char opt[9]; read(m);read(k); while (m--){ scanf("%s%d", opt, &x); it1 = st.lower_bound(x-k); it2 = st.upper_bound(x+k); if (opt[0] == 'a') st.insert(x); else if (opt[0] == 'd'){ if (it1 != st.end() && it1 != it2) st.erase(it1, it2); } else{ if (it1 != st.end() && it1 != it2) printf("Yes\n"); else printf("No\n"); } } return 0; }
全部评论
(0) 回帖