이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n,q;
cin >> n >> q;
vector<ll> L(n-1),R(n-1);
for(ll i = 0;i<n-1;i++) cin >> L[i] >> R[i];
while(q--){
ll t,a,b,c,d;
cin >> t >> a >> b >> c;a--;
if (t==1){
L[a] = b;
R[a] = c;
}else{
c--;
cin >> d;
ll ans = 0;
ll t = b;
ll cur = a;
if (c>a){
while(cur<c){
cur++;
t++;
if (t>R[cur-1]){
ans += t-R[cur-1];
t = R[cur-1];
}
t = max(t,L[cur-1]+1);
//cout << "at " << cur << ", t=" << t << "\n";
}
}else{
while(cur>c){
cur--;
t++;
if (t>R[cur]){
ans += t-R[cur];
t = R[cur];
}
t = max(t,L[cur]+1);
//cout << "at " << cur << ", t=" << t << "\n";
}
}
if (t>d) ans += t-d;
cout << ans << "\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |