一维vector
abs绝对值因为会有负数
C++ 代码
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
vector<int> a[100010];
int main(){
int n;
cin>>n;
char f;
int num;
bool flag = 0;
while(n--){
cin>>f;
if(f == 'I'){
cin>>num;
a[abs(num % 100000)].push_back(num);
}
else{
flag = 0;
cin>>num;
for(int i = 0;i < a[abs(num % 100000)].size();i++){
if(a[abs(num % 100000)][i] == num){
cout<<"Yes"<<endl;
flag = 1;
break;
}
}
if(!flag) cout << "No" << endl;
}
}
}