제출 #105848

#제출 시각아이디문제언어결과실행 시간메모리
105848Pro_ktmrBitaro, who Leaps through Time (JOI19_timeleap)C++14
4 / 100
10 ms412 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...