#pragma GCC optimization "O2"
#pragma GCC optimization "unroll-loop"
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 1e5 + 9;
const ll mod = 1e9 + 7;
const ll Log2 = 20;
typedef pair<ll,ll> LL;
ll n,Q,k,x,a[N];
ll st[4*N];
void upd(ll id,ll l,ll r,ll u,ll val){
if (u < l||r < u) return;
if (l == r){
st[id] = val; return;
}
ll mid = (l + r)/2;
upd(id*2,l,mid,u,val); upd(id*2 + 1,mid + 1,r,u,val);
st[id] = st[id*2] + st[id*2 + 1];
}
ll Get(ll id,ll l,ll r,ll u,ll v){
if (v < l||r < u) return 0;
if (u <= l&&r <= v) return st[id];
ll mid = (l + r)/2;
return Get(id*2,l,mid,u,v) + Get(id*2 + 1,mid + 1,r,u,v);
}
ll Walk(ll id,ll l,ll r,ll val){
///first value which > val
if (l == r){
if (st[id] > val) return l;
return n + 1;
}
ll mid = (l + r)/2;
if (st[id*2] > val) return Walk(id*2,l,mid,val);
return Walk(id*2 + 1,mid + 1,r,val - st[id*2]);
}
ll type,l,r;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define task "tst"
if (fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
//freopen(task".out", "w", stdout);
}
cin>>n>>Q>>k;
for (ll i = 1;i <= n;i++) cin>>x,a[i] = x;
while(Q--){
cin>>type>>l>>r;
if (type == 1) a[l] = r;
else if (type == 2){
if (k > 1){
while(l <= r){
a[l] /= k;
l++;
}
}
}
else{
ll res = 0;
while(l <= r) res += a[l],l++; cout<<res<<"\n";
}
}
}
Compilation message
sterilizing.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
1 | #pragma GCC optimization "O2"
|
sterilizing.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
2 | #pragma GCC optimization "unroll-loop"
|
sterilizing.cpp: In function 'int main()':
sterilizing.cpp:73:13: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
73 | while(l <= r) res += a[l],l++; cout<<res<<"\n";
| ^~~~~
sterilizing.cpp:73:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
73 | while(l <= r) res += a[l],l++; cout<<res<<"\n";
| ^~~~
sterilizing.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
55 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
236 ms |
840 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
364 KB |
Output is correct |
2 |
Correct |
351 ms |
484 KB |
Output is correct |
3 |
Correct |
540 ms |
496 KB |
Output is correct |
4 |
Correct |
1175 ms |
468 KB |
Output is correct |
5 |
Correct |
4853 ms |
856 KB |
Output is correct |
6 |
Correct |
4828 ms |
960 KB |
Output is correct |
7 |
Correct |
491 ms |
896 KB |
Output is correct |
8 |
Correct |
4871 ms |
852 KB |
Output is correct |
9 |
Execution timed out |
5070 ms |
704 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1757 ms |
1464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |