rt,测试点反馈信息:
Received signal 6: Aborted/IOT trap.
蒟蒻代码如下:
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int n, ope, len, num;
map<int, bool> gar;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>ope>>len;
switch(ope){
case 1:
if(gar.count(len))
cout<<"Already Exist"<<'\n';
else
gar[len]=1, ++num;
break;
case 2:
if(!num) cout<<"Empty"<<'\n';
else {
--num;
if(gar.count(len)) cout<<len<<'\n', gar.erase(len);
else{
gar[len]=1;
map<int, bool>::iterator l=gar.find(len);
map<int, bool>::iterator r=l;
if(r==gar.end())
cout<<(--r)->first<<'\n', gar.erase(l);
else if(l==gar.begin())
cout<<(++r)->first<<'\n', gar.erase(r);
else{
--l; ++r;
cout<<l->first<<' '<<r->first<<'\n';
if(len-(l->first)<=(r->first)-len)
cout<<l->first<<'\n', gar.erase(l);
else
cout<<r->first<<'\n', gar.erase(r);
}
gar.erase(len);
}
}
}
}
return 0;
}
p.s:定义l、r时本试图使用auto,但报错并反馈'' 'l' does not name a type.'' 如果可以的话想一并请教