이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back
int N,Q;
int L[300000],R[300000];
int main(){
cin >> N >> Q;
if(N > 1000 || Q > 1000) return -1;
for(int i=0; i<N-1; i++) cin >> L[i] >> R[i];
for(int i=0; i<Q; i++){
int T;
cin >> T;
if(T == 1){
int P,S,T;
cin >> P >> S >> T;
P--;
L[P] = S;
R[P] = T;
}
else{
int A,B,C,D;
cin >> A >> B >> C >> D;
A--; C--;
int nowP = A;
int nowT = B;
LL ans = 0;
if(A <= C){
while(nowP != C){
if(L[nowP] <= nowT && nowT <= R[nowP]-1){
nowT++;
nowP++;
}
else if(nowT < L[nowP]){
nowT = L[nowP]+1;
nowP++;
}
else{
ans += nowT - (R[nowP]-1);
nowT = R[nowP];
nowP++;
}
}
if(nowT > D) ans += nowT - D;
}
else{
while(nowP != C){
if(L[nowP-1] <= nowT && nowT <= R[nowP-1]-1){
nowT++;
nowP--;
}
else if(nowT < L[nowP-1]){
nowT = L[nowP-1]+1;
nowP--;
}
else{
ans += nowT - (R[nowP-1]-1);
nowT = R[nowP-1];
nowP--;
}
}
if(nowT > D) ans += nowT - D;
}
cout << ans << endl;
}
}
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... |