제출 #859923

#제출 시각아이디문제언어결과실행 시간메모리
859923aykhn입자 가속기 (IZhO11_collider)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> // author : aykhn using namespace std; using namespace __gnu_pbds; typedef long long ll; #define pb push_back #define ins insert #define mpr make_pair #define all(v) v.begin(), v.end() #define bpc __builtin_popcount #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define int ll #define infll 0x3F3F3F3F3F3F3F3F #define inf 0x3F3F3F3F template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; signed main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); ordered_set<pair<pii, char>> os; int n, q; cin >> n >> q; string s; cin >> s; s = "." + s; for (int i = 1; i <= n; i++) os.ins(mpr(mpr(i, 0), s[i])); for (int i = 1; i <= q; i++) { char ch; cin >> ch; if (ch == 'a') { int l, r; cin >> l >> r; auto it = os.find_by_order(l - 1); auto it1 = os.find_by_order(r - 1); pair<pii, char> p = *it, p1 = *it1; os.erase(it); p.fi = p1.fi; p.fi.se = i; os.ins(p); } else { int ind; cin >> ind; cout << (*os.find_by_order(ind - 1)).se << '\n'; } for (pair<pii, char> p : os) { cout << p.se; } cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...