# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
862601 |
2023-10-18T15:27:10 Z |
Irate |
Trading (IZhO13_trading) |
C++14 |
|
197 ms |
17488 KB |
#include<bits/stdc++.h>
using namespace std;
struct SegmentTree{
vector<int>sTree;
vector<int>lazy;
SegmentTree(int n){
sTree.resize(4 * n);
lazy.resize(4 * n);
}
void Propagate(int node, int l, int r){
if(!lazy[node])return;
if(l == r)sTree[node] = max(sTree[node], lazy[node]);
if(l != r){
lazy[node * 2] = max(lazy[node * 2], lazy[node]);
lazy[node * 2 + 1] = max(lazy[node * 2 + 1], ((2 * lazy[node] + r - l) >> 1) + 1);
}
lazy[node] = 0;
}
void R_Update(int node, int l, int r, int ql, int qr, int x){
Propagate(node, l, r);
if(ql <= l && r <= qr){
lazy[node] = x + l - ql;
Propagate(node, l, r);
return;
}
if(ql > r || l > qr)return;
int mid = (l + r) >> 1;
R_Update(node * 2, l, mid, ql, qr, x);
R_Update(node * 2 + 1, mid + 1, r, ql, qr, x);
}
int Query(int node, int l, int r, int pos){
Propagate(node, l, r);
if(l == r)return sTree[node];
int mid = (l + r) >> 1;
if(pos <= mid)return Query(node * 2, l, mid, pos);
return Query(node * 2 + 1, mid + 1, r, pos);
}
};
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
SegmentTree tree(n);
while(m--){
int l, r, x;
cin >> l >> r >> x;
tree.R_Update(1, 1, n, l, r, x);
}
for(int i = 1;i <= n;++i){
cout << tree.Query(1, 1, n, i) << " ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
94 ms |
8708 KB |
Output is correct |
8 |
Correct |
104 ms |
9764 KB |
Output is correct |
9 |
Correct |
116 ms |
10208 KB |
Output is correct |
10 |
Correct |
119 ms |
10768 KB |
Output is correct |
11 |
Correct |
120 ms |
12028 KB |
Output is correct |
12 |
Correct |
135 ms |
12128 KB |
Output is correct |
13 |
Correct |
137 ms |
13104 KB |
Output is correct |
14 |
Correct |
143 ms |
13396 KB |
Output is correct |
15 |
Correct |
159 ms |
14164 KB |
Output is correct |
16 |
Correct |
164 ms |
14460 KB |
Output is correct |
17 |
Correct |
161 ms |
14968 KB |
Output is correct |
18 |
Correct |
167 ms |
15556 KB |
Output is correct |
19 |
Correct |
171 ms |
15612 KB |
Output is correct |
20 |
Correct |
197 ms |
17488 KB |
Output is correct |