#include <bits/stdc++.h>
using namespace std;
int n,q;
char a;
int b,c;
multiset<pair<int,int> > s;
map<pair<int,int>,int > mp;
int par(pair<int,int> k,pair<int,int> z)
{
return ((k.first<z.first)||(k.second<z.second));
}
int bul(pair<int,int> &p)
{
auto up=lower_bound(s.begin(),s.end(),p,par);
if(up==s.end())
{
cout<<"-1"<<endl;
return 0;
}
cout<<(*up).first<<endl;
}
int main()
{
scanf("%d%d",&n,&q);
while(q--)
{
cin>>a>>b>>c;
if(mp[{c,b}]==1)
{
printf("%d\n",c);
continue;
}
mp[{c,b}]=1;
if(a=='M')
{
s.insert({c,-b});
}
else
{
pair<int,int> pa={c,-b};
bul(pa);
}
}
return 0;
}
Compilation message
deda.cpp: In function 'int bul(std::pair<int, int>&)':
deda.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
25 | }
| ^
deda.cpp: In function 'int main()':
deda.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | scanf("%d%d",&n,&q);
| ~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
460 KB |
Execution killed with signal 6 |
2 |
Runtime error |
3 ms |
460 KB |
Execution killed with signal 6 |
3 |
Runtime error |
3 ms |
588 KB |
Execution killed with signal 6 |
4 |
Runtime error |
6 ms |
716 KB |
Execution killed with signal 6 |
5 |
Runtime error |
3 ms |
588 KB |
Execution killed with signal 6 |
6 |
Runtime error |
3 ms |
588 KB |
Execution killed with signal 6 |
7 |
Runtime error |
3 ms |
588 KB |
Execution killed with signal 6 |