第一行有2个正整数m,k。
接下来m行,每行描述一种操作:add x,del x或query x。
对于每个query操作,输出一行,包含一个单词“Yes”或“No”,表示该人是否可以打开指纹锁。
对于100%的测试数据:
1 ≤ k,m ≤ 1000000
数据量较大,注意使用更快的输入输出方式。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e6+50;
const ll inf=0x3f3f3f3f3f3f;
int k;
struct node{
bool operator()(int a,int b){
if(abs(a-b)<=k)return false;
return a<b;
}
};
set<int,node>st;
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int n;
cin>>n>>k;
char s[10];
while(n--){
int x;
cin>>s>>x;
if(s[0]==‘a‘){
if(st.find(x)==st.end())st.insert(x);
}
else if(s[0]==‘d‘)st.erase(x);
else{
if(st.find(x)!=st.end())cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return 0;
}
原文:https://www.cnblogs.com/luowentao/p/9502638.html