#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (100005)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
struct LAZYSEG {
ll dt[MAXN<<2], lz[MAXN<<2];
void init() { fill(lz, lz+(MAXN<<2), 1); }
void uplz(int idx, int R) { lz[idx] *= R; if(INF < lz[idx]) lz[idx] = INF; }
void prop(int idx, int S, int E) {
if(1 == lz[idx]) return;
dt[idx] /= lz[idx];
if(S != E) { uplz(idx*2, lz[idx]); uplz(idx*2+1, lz[idx]); }
lz[idx] = 1;
}
void opSeg(int idx, int S, int E, int P, int Q, int R) {
prop(idx, S, E);
if(E < P || Q < S) return;
if(P <= S && E <= Q) { uplz(idx, R); prop(idx, S, E); return; }
const int M = (S+E)/2;
opSeg(idx*2, S, M, P, Q, R); opSeg(idx*2+1, M+1, E, P, Q, R);
dt[idx] = dt[idx*2] + dt[idx*2+1];
}
void inSeg(int idx, int S, int E, int X, int R) {
prop(idx, S, E); if(E < X || X < S) return;
if(S == E) { dt[idx] = R; return; }
const int M = (S+E)/2;
inSeg(idx*2, S, M, X, R); inSeg(idx*2+1, M+1, E, X, R);
dt[idx] = dt[idx*2] + dt[idx*2+1];
}
ll getSeg(int idx, int S, int E, int P, int Q) {
prop(idx, S, E);
if(Q < P || E < P || Q < S) return 0;
if(P <= S && E <= Q) return dt[idx];
const int M = (S+E)/2;
return getSeg(idx*2, S, M, P, Q) + getSeg(idx*2+1, M+1, E, P, Q);
}
};
LAZYSEG ST;
int N, Q, K;
int main() {
ST.init();
scanf("%d%d%d", &N, &Q, &K);
for(int i = 1, c; i <= N; i++) {
scanf("%d", &c); ST.inSeg(1, 1, N, i, c);
}
for(int type, a, b; Q--;) {
scanf("%d%d%d", &type, &a, &b);
if(1 == type) ST.inSeg(1, 1, N, a, b);
else if(2 == type) ST.opSeg(1, 1, N, a, b, K);
else printf("%lld\n", ST.getSeg(1, 1, N, a, b));
}
return 0;
}
Compilation message
sterilizing.cpp: In function 'int main()':
sterilizing.cpp:72:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &N, &Q, &K);
^
sterilizing.cpp:74:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &c); ST.inSeg(1, 1, N, i, c);
^
sterilizing.cpp:77:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &type, &a, &b);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
8288 KB |
Output is correct |
2 |
Correct |
99 ms |
8288 KB |
Output is correct |
3 |
Correct |
106 ms |
8288 KB |
Output is correct |
4 |
Correct |
123 ms |
8288 KB |
Output is correct |
5 |
Correct |
166 ms |
8288 KB |
Output is correct |
6 |
Correct |
169 ms |
8288 KB |
Output is correct |
7 |
Correct |
156 ms |
8288 KB |
Output is correct |
8 |
Correct |
146 ms |
8288 KB |
Output is correct |
9 |
Correct |
166 ms |
8288 KB |
Output is correct |
10 |
Correct |
123 ms |
8288 KB |
Output is correct |
11 |
Correct |
139 ms |
8288 KB |
Output is correct |
12 |
Correct |
119 ms |
8288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
53 ms |
8288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
163 ms |
8288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |