Submission #956956

# Submission time Handle Problem Language Result Execution time Memory
956956 2024-04-02T17:56:54 Z Acanikolic Addk (eJOI21_addk) C++14
0 / 100
1764 ms 1732 KB
#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 = 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 330 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1764 ms 1732 KB Output isn't correct
2 Halted 0 ms 0 KB -