답안 #481048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481048 2021-10-19T10:55:12 Z dxz05 입자 가속기 (IZhO11_collider) C++14
100 / 100
478 ms 2620 KB
#pragma GCC optimize("Ofast,O2,O3,unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << "[" << H << "]";
    debug_out(T...);
}

#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SZ(s) ((int)s.size())
#define all(x) (x).begin(), (x).end()
#define lla(x) (x).rbegin(), (x).rend()

clock_t startTime;

double getCurrentTime() {
    return (double) (clock() - startTime) / CLOCKS_PER_SEC;
}

#define MP make_pair

typedef long long ll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.000001;
const int MOD = 998244353;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 1e6 + 2e5;
const int M = 5222;

void solve(int TC) {
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    while (q--){
        char c;
        cin >> c;

        if (c == 'a'){
            int i, j;
            cin >> i >> j;
            --i, --j;
            char ch = s[i];
            s.erase(s.begin() + i);
            s.insert(s.begin() + j, ch);
        } else {
            int i;
            cin >> i;
            cout << s[i - 1] << endl;
        }
    }

}

int main() {
    startTime = clock();
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int TC = 1;
//    cin >> TC;

    for (int test = 1; test <= TC; test++) {
        //debug(test);
        //cout << "Case #" << test << ": ";
        solve(test);
    }

    cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 236 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 18 ms 708 KB Output is correct
4 Correct 129 ms 2144 KB Output is correct
5 Correct 279 ms 2156 KB Output is correct
6 Correct 366 ms 2280 KB Output is correct
7 Correct 342 ms 2536 KB Output is correct
8 Correct 171 ms 2408 KB Output is correct
9 Correct 478 ms 2620 KB Output is correct
10 Correct 307 ms 2556 KB Output is correct