# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1007592 |
2024-06-25T08:37:28 Z |
Whisper |
Addk (eJOI21_addk) |
C++17 |
|
77 ms |
7488 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPD(i, n) for (int i = (n) - 1; i >= 0; --i)
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*
Phu Trong from Nguyen Tat Thanh High School for gifted student
*/
template <class X, class Y>
bool minimize(X &x, const Y &y){
X eps = 1e-9;
if (x > y + eps) {x = y; return 1;}
return 0;
}
template <class X, class Y>
bool maximize(X &x, const Y &y){
X eps = 1e-9;
if (x + eps < y) {x = y; return 1;}
return 0;
}
#define MAX 100005
int nArr, numRot, numQuery;
int A[MAX];
int sum[MAX];
int lz[4 * MAX], st[4 * MAX];
void pushDown(int id, int l, int r){
if (!lz[id]) return;
int m = (l + r) >> 1;
st[id << 1] += (m - l + 1) * lz[id];
st[id << 1 | 1] += (r - m) * lz[id];
lz[id << 1] += lz[id];
lz[id << 1 | 1] += lz[id];
lz[id] = 0;
}
void upd(int id, int l, int r, int u, int v, int val){
if (u > r || v < l) return;
if (u <= l && v >= r){
st[id] += (r - l + 1) * val;
lz[id] += val;
return;
}
int m = (l + r) >> 1;
pushDown(id, l, r);
upd(id << 1, l, m, u, v, val);
upd(id << 1 | 1, m + 1, r, u, v, val);
st[id] = st[id << 1] + st[id << 1 | 1];
}
int query(int id, int l, int r, int u, int v){
if (u > r || v < l) return 0;
if (u <= l && v >= r) return st[id];
int m = (l + r) >> 1;
pushDown(id, l, r);
int ql = query(id << 1, l, m, u, v);
int qr = query(id << 1 | 1, m + 1, r, u, v);
return (ql + qr);
}
void process(void){
cin >> nArr >> numRot;
for (int i = 1; i <= nArr; ++i) cin >> A[i], upd(1, 1, nArr, i, nArr, A[i]);
cin >> numQuery;
for (int i = 1; i <= numQuery; ++i){
int cmd, l, r, m;
cin >> cmd;
if(cmd == 1){
vector<int> pos(numRot), val;
for(int&v : pos) cin >> v;
for (int j = 1; j < numRot; ++j) val.push_back(A[pos[j]]);
val.push_back(A[0]);
for (int j = 0; j < numRot; ++j){
upd(1, 1, nArr, pos[j], nArr, val[j] - A[pos[j]]);
A[pos[j]] = val[j];
}
}
else{
cin >> l >> r >> m;
cout << query(1, 1, nArr, l + m - 1, r) - query(1, 1, nArr, l - 1, r - m) << '\n';
}
}
}
signed main(){
#define name "Whisper"
cin.tie(nullptr) -> sync_with_stdio(false);
//freopen(name".inp", "r", stdin);
//freopen(name".out", "w", stdout);
process();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
5468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
7488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |