Submission #621429

# Submission time Handle Problem Language Result Execution time Memory
621429 2022-08-03T18:59:40 Z pakapu Addk (eJOI21_addk) C++14
36 / 100
2000 ms 1604 KB
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, k;
    cin >> n >> k;

    vector<long long> sg(n);

    for(int i = 0; i < n; i++) {
        cin >> sg[i];
    }

    int q;
    cin >> q;
    while(q--) {
        int x;
        cin >> x;

        if(x == 1) {
            vector<int> a(k);
            vector<long long> tmp(k);

            for(int i = 0; i < k; i++) {
                cin >> a[i];
                a[i]--;
                tmp[i] = sg[a[i]];
            }
            for(int i = 0; i < k; i++) {
                sg[a[((i - 1) % k + k) % k]] = tmp[i];
            }
        }
        else if(x == 2) {
            int l, r, m;
            cin >> l >> r >> m;
            l--;
            r--;
            long long s = 0;
            long long mul = 1;
            long long mm = min(r - l + 1 - m + 1, m);
            for(int i = l; i < (r + l) / 2; i++) {
                s += sg[i] * min(mul, mm);
                mul++;
            }
            mul = 1;
            for(int i = r; i >= (r + l) / 2; i--) {
                s += sg[i] * min(mul, mm);
                mul++;
            }
            cout << s << '\n';
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 7 ms 348 KB Output is correct
5 Correct 12 ms 340 KB Output is correct
6 Correct 17 ms 396 KB Output is correct
7 Correct 25 ms 436 KB Output is correct
8 Correct 33 ms 436 KB Output is correct
9 Correct 66 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 260 ms 748 KB Output is correct
2 Correct 567 ms 928 KB Output is correct
3 Correct 1025 ms 1320 KB Output is correct
4 Execution timed out 2060 ms 1516 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1103 ms 1260 KB Output is correct
2 Execution timed out 2094 ms 1604 KB Time limit exceeded
3 Halted 0 ms 0 KB -