제출 #104974

#제출 시각아이디문제언어결과실행 시간메모리
104974Just_Solve_The_ProblemBitaro, who Leaps through Time (JOI19_timeleap)C++11
4 / 100
3006 ms2780 KiB
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int N = (int)3e5 + 7;

int n, q;
int L[N], R[N];

main() {
	scanf("%d %d", &n, &q);
	for (int i = 1; i < n; i++) {
		scanf("%d %d", &L[i], &R[i]);
	}
	while (q--) {
		int tp;
		scanf("%d", &tp);
		if (tp == 1) {
			int ind, l, r;
			scanf("%d %d %d", &ind, &l, &r);
			L[ind] = l;
			R[ind] = r;
		} else {
			int a, b, c, d;
			scanf("%d %d %d %d", &a, &b, &c, &d);
			ll ans = 0;
			if (a < c) {
				int cur = b;
				for (int i = a; i < c; i++) {
					if (L[i] <= cur && cur + 1 <= R[i]) {
						cur++;
					} else {
						if (cur < L[i]) cur = L[i] + 1;
						else {
							ans += (cur - R[i] + 1);
							cur = R[i];
						}
					}
				}
				if (cur > d) {
					ans += (cur - d);
				}
			} else {
				int cur = b;
				for (int i = a - 1; i >= c; i--) {
					if (L[i] <= cur && cur + 1 <= R[i]) {
						cur++;
					} else {
						if (cur < L[i]) cur = L[i] + 1;
						else {
							ans += (cur - R[i] + 1);
							cur = R[i];
						}
					}
				}
				if (cur > d) {
					ans += (cur - d);
				}
			}
			printf("%lld\n", ans);
		}
	}
}

컴파일 시 표준 에러 (stderr) 메시지

timeleap.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
timeleap.cpp: In function 'int main()':
timeleap.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
timeleap.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &L[i], &R[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &tp);
   ~~~~~^~~~~~~~~~~
timeleap.cpp:22:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d %d", &ind, &l, &r);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:27:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d %d %d", &a, &b, &c, &d);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...