From 4fec3f5288679778bf55b0a11444458e9c950202 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 2 Jul 2022 20:32:05 +0800 Subject: [PATCH] C - Rotation https://atcoder.jp/contests/abc258/submissions/32905877 --- AtCoder/ABC258/C/C.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 AtCoder/ABC258/C/C.cpp diff --git a/AtCoder/ABC258/C/C.cpp b/AtCoder/ABC258/C/C.cpp new file mode 100644 index 00000000..b1ae0388 --- /dev/null +++ b/AtCoder/ABC258/C/C.cpp @@ -0,0 +1,31 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +int n, q, cnt; +std::string s; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> q >> s; + + while (q--) { + int op, x; + + cin >> op >> x; + + if (op == 1) { + cnt = (cnt + x) % n; + } else { + x = (x - cnt + n) % n; + cout << s.at(x ? x - 1 : n - 1) << endl; + } + } + + return 0; +}