Submission #170685

#TimeUsernameProblemLanguageResultExecution timeMemory
170685div2derCollider (IZhO11_collider)C++14
0 / 100
2 ms376 KiB
#include <iostream> #include <vector> using namespace std; #define sz(s) (int)(s.size()) #define eb emplace_back const int N = 2e5 + 5; void solve() { int n, m; cin >> n >> m; string s; cin >> s; s = "#" + s; while(m--) { char type; cin >> type; if (type == 'a') { int l, r; cin >> l >> r; if (l > r) { swap(l, r); char x = s[r]; for (int i = r - 1; i >= l; -- i) s[i + 1] = s[i]; s[l] = x; } else if (l <= r) { char x = s[l]; for (int i = l + 1; i <= r; ++ i) s[i - 1] = s[i]; s[r] = x; } } else { int pos; cin >> pos; cout << s[pos] << '\n'; } } } int main () { cerr << "Ready\n"; solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...