#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define sz size()
#define ll long long
#define pii pair <int, int>
const int N = 1e5 + 5;
int l[N], r[N], n, m, jog, w[N];
bool vis[N];
vector <pii> v[N];
int st[3 * N];
void update (int idx, int x, int y, int val) {
if (x == y) {
st[idx] = w[x];
return;
}
int mid = (x + y) / 2;
if (val <= mid) update (idx * 2, x, mid, val);
else update (idx * 2 + 1, mid + 1, y, val);
st[idx] = min (st[idx * 2], st[idx * 2 + 1]);
}
int jogap (int idx, int x, int y, int l1, int r1) {
// cout << "--> " << x << " " << y << " " << l1 << " " << r1 << " " << idx << " " << st[idx] << "\n";
if (l1 <= x and y <= r1) return st[idx];
if (l1 > y or x > r1) {
// cout << "gaytdy\n";
return 1e9;
}
int mid = (x + y) / 2;
return min (jogap (idx * 2, x, mid, l1, r1), jogap (idx * 2 + 1, mid + 1, y, l1, r1));
}
void dfs (int x, int y) {
jog++;
vis[x] = 1;
for (pii i : v[x]) {
if (vis[i.ff] or y > i.ss) continue;
dfs (i.ff, y);
}
}
int main () {
// ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// freopen ("input.txt", "r", stdin);
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
cin >> l[i] >> r[i] >> w[i];
}
int q;
cin >> q;
for (int i = 1; i < n; ++i) {
update (1, 1, n - 1, i);
}
while ( q-- ) {
int typ, l1, r1;
cin >> typ >> l1 >> r1;
if (typ == 1) {
w[l1] = r1;
update (1, 1, n - 1, l1);
}
else {
int x = 1, y = l1 - 1, jog1 = 0, jog2 = 0;
while (x <= y) {
int md = (x + y) / 2;
int kk = jogap (1, 1, n - 1, l1 - md, l1 - 1);
if (kk < r1) {
y = md - 1;
}
else {
jog1 = md;
x = md + 1;
}
}
x = 1, y = n - l1;
while (x <= y) {
int md = (x + y) / 2;
if (jogap (1, 1, n - 1, l1, l1 + md - 1) < r1) {
y = md - 1;
}
else {
jog2 = md;
x = md + 1;
}
}
cout << jog1 + jog2 + 1 << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2704 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |