mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 14:16:28 +00:00
P1503 鬼子进村
R70496187
This commit is contained in:
parent
351aa5f0a0
commit
6977b74b41
35
Luogu/P1503/P1503.cpp
Normal file
35
Luogu/P1503/P1503.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
int n, m, x;
|
||||
char op;
|
||||
std::set<int> set;
|
||||
std::stack<int> st;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin >> n >> m;
|
||||
set.insert(0);
|
||||
set.insert(n + 1);
|
||||
while (m--) {
|
||||
cin >> op;
|
||||
if (op == 'D') {
|
||||
cin >> x;
|
||||
set.insert(x);
|
||||
st.push(x);
|
||||
} else if (op == 'R') {
|
||||
set.erase(st.top());
|
||||
st.pop();
|
||||
} else {
|
||||
cin >> x;
|
||||
auto it = set.lower_bound(x);
|
||||
cout << (*it == x ? 0 : *it - *--it - 1) << endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user