답안 #105848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105848 2019-04-15T10:38:46 Z Pro_ktmr Bitaro, who Leaps through Time (JOI19_timeleap) C++14
4 / 100
10 ms 412 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 412 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 8 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 8 ms 384 KB Output is correct
24 Correct 10 ms 356 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 6 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 8 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 8 ms 384 KB Output is correct
37 Correct 6 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 6 ms 384 KB Output is correct
40 Correct 9 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 412 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 8 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 8 ms 384 KB Output is correct
24 Correct 10 ms 356 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 6 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 8 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 8 ms 384 KB Output is correct
37 Correct 6 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 6 ms 384 KB Output is correct
40 Correct 9 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
43 Halted 0 ms 0 KB -