Submission #958789

#TimeUsernameProblemLanguageResultExecution timeMemory
958789AcanikolicAddk (eJOI21_addk)C++14
36 / 100
2057 ms2412 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define int long long using namespace std; const int N = 1e5 + 10; const int mod = 998244353; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n,k; cin >> n >> k; vector<int>a(n + 1); for(int i = 1; i <= n; i++) cin >> a[i]; int q; cin >> q; while(q--) { int type; cin >> type; if(type == 1) { vector<int>b(k + 1),c(k + 1); for(int i = 1; i <= k; i++) cin >> b[i]; for(int i = 1; i <= k - 1; i++) c[i] = b[i + 1]; c[k] = b[1]; vector<int>cpy = a; for(int i = 1; i <= k; i++) cpy[b[i]] = a[c[i]]; a = cpy; }else { int l,r,m,res = 0; cin >> l >> r >> m; vector<int>pref(n + 1); for(int i = 1; i <= n; i++) pref[i] = pref[i - 1] + a[i]; for(int i = l; i <= r; i++) { if(i + m - 1 <= r) res += pref[i + m - 1] - pref[i - 1]; } cout << res << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...