이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
struct SegTree {
int l, r, mid;
int val = INF;
SegTree *lc, *rc;
SegTree(int _l, int _r): l(_l), r(_r){
mid = (l + r) / 2;
if (l == r - 1) return;
lc = new SegTree(l, mid);
rc = new SegTree(mid, r);
}
void pull(){
val = max(lc->val, rc->val);
}
void update(int i, int u){
if (l == r - 1)
return void(val = u);
if (i < mid)
lc->update(i, u);
else
rc->update(i, u);
pull();
}
int query(int ll, int rr){
if (ll <= l && rr >= r)
return val;
int ret = INF;
if (ll < mid)
ret = min(ret, lc->query(ll, rr));
if (mid < rr)
ret = min(ret, rc->query(ll, rr));
return ret;
}
};
int main(){
cin.tie(0)->sync_with_stdio(0);
int n, m; cin >> n >> m;
SegTree st(0, m);
for (int i = 0; i < m; i++){
int u, v, w; cin >> u >> v >> w;
u--, v--;
st.update(i, w);
}
int q; cin >> q;
while (q--){
int t; cin >> t;
if (t == 1){
int i, w; cin >> i >> w;
i--;
st.update(i, w);
}else{
int u, w; cin >> u >> w;
u--;
int l = u, r = n - 1;
while (l < r - 1){
int mid = (l + r) / 2;
if (st.query(u, mid) < w)
r = mid;
else
l = mid;
}
cout << l - u + 1 << '\n';
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |