#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
using namespace std;
typedef long long ll;
using pii = pair<int, int>;
int n, k;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
vector<int> tm(n + 2, -1);
set<int> incr, decr;
for(int i = 0; i <= n + 1; i++){
incr.insert(i);
decr.insert(i);
}
int q = n + k - 1;
for(int i = 0; i < q; i++){
string s;
cin >> s;
int a = -1, d;
if(s == "S"){
int u, v;
cin >> u >> v;
if(u > v) swap(u, v);
assert(u + 1 == v);
tm[u] = i;
if(tm[u - 1] != -1){
if(tm[u - 1] < tm[u]) incr.erase(u);
else decr.erase(u);
}
if(tm[v] != -1){
if(tm[u] < tm[v]) incr.erase(v);
else decr.erase(v);
}
continue;
}
if(s == "Q"){
cin >> a >> d;
}
else{
cin >> d;
}
auto it = prev(decr.lower_bound(d));
if(*it == d) it = prev(it);
int l = *it;
int r = *incr.upper_bound(d);
if(tm[d] == -1) r = d;
if(tm[d - 1] == -1) l = d;
//cerr << "test " << l << " " << r << "\n";
if(a == -1) cout << r - l + 1 << "\n";
else{
if(l <= a && a <= r) cout << "yes\n";
else cout << "no\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
700 KB |
Output is correct |
2 |
Correct |
352 ms |
12500 KB |
Output is correct |
3 |
Correct |
315 ms |
12388 KB |
Output is correct |
4 |
Correct |
221 ms |
12420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
700 KB |
Output is correct |
2 |
Correct |
352 ms |
12500 KB |
Output is correct |
3 |
Correct |
315 ms |
12388 KB |
Output is correct |
4 |
Correct |
221 ms |
12420 KB |
Output is correct |
5 |
Correct |
41 ms |
1348 KB |
Output is correct |
6 |
Correct |
313 ms |
15296 KB |
Output is correct |
7 |
Correct |
232 ms |
15452 KB |
Output is correct |
8 |
Correct |
299 ms |
14916 KB |
Output is correct |
9 |
Correct |
303 ms |
15208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
680 KB |
Output is correct |
2 |
Correct |
354 ms |
12488 KB |
Output is correct |
3 |
Correct |
311 ms |
12480 KB |
Output is correct |
4 |
Correct |
209 ms |
12404 KB |
Output is correct |
5 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
680 KB |
Output is correct |
2 |
Correct |
354 ms |
12488 KB |
Output is correct |
3 |
Correct |
311 ms |
12480 KB |
Output is correct |
4 |
Correct |
209 ms |
12404 KB |
Output is correct |
5 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |