#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 2e9 + 1;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
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);
for(int i = 1; i <= k; i++) cin >> b[i];
vector<int>c(k + 1);
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,res = 0,m;
cin >> l >> r >> m;
for(int i = l; i <= r; i++) {
int wtf = min(i - l + 1,min(m,r - i + 1));
res += wtf * a[i];
}
cout << res << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
342 ms |
1224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1603 ms |
3336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |