Submission #446880

#TimeUsernameProblemLanguageResultExecution timeMemory
446880wiwihoInside information (BOI21_servers)C++14
10 / 100
354 ms15452 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...