Submission #958791

#TimeUsernameProblemLanguageResultExecution timeMemory
958791gmroh06복사 붙여넣기 2 (JOI15_copypaste2)C++14
100 / 100
185 ms11024 KiB
#import <bits/stdc++.h>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

int main() {
    fastio();

    ll k, m, n;
    string s, ans;

    cin >> k >> m >> s >> n;

    vector<ll> a(n), b(n), c(n);

    for (ll i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (ll i = 0; i < k; i++) {
        ll idx = i;

        for (ll j = n - 1; j >= 0; j--) {
            if (idx < c[j]) continue;

            if (idx < b[j] + c[j] - a[j]) {
                idx += a[j] - c[j];
            } else {
                idx += a[j] - b[j];
            }
        }

        ans += s[idx];
    }

    cout << ans;

    return 0;
}

Compilation message (stderr)

copypaste2.cpp:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    1 | #import <bits/stdc++.h>
      |  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...