Submission #376201

# Submission time Handle Problem Language Result Execution time Memory
376201 2021-03-11T04:28:29 Z Kevin_Zhang_TW Bitaro, who Leaps through Time (JOI19_timeleap) C++17
4 / 100
65 ms 4692 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l) == r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
const int MAX_N = 300010;

#define int ll

int n, q;
int lt[MAX_N], rt[MAX_N];

int qt[MAX_N], pt[MAX_N], st[MAX_N], et[MAX_N];

int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> q;
	for (int i = 1;i < n;++i)
		cin >> lt[i] >> rt[i], --rt[i];

	if (n > 1000) return -1;

	for (int qt, pt, st, et, at, bt, ct, dt, i = 0;i < q;++i) {
		cin >> qt;
		if (qt == 1) {
			cin >> pt >> st >> et;
			lt[pt] = st;
			rt[pt] = et-1;
		}
		if (qt == 2) {
			cin >> at >> bt >> ct >> dt;
			ll time = bt, res = 0;

			while (at < ct) {
				chmax(time, lt[at]);
				res += max<ll>(0, time - rt[at]);
				chmin(time, rt[at]);
				++time;
				++at;
			}

			while (at > ct) {
				--at;
				chmax(time, lt[at]);
				res += max<ll>(0, time - rt[at]);
				chmin(time, rt[at]);
				++time;
			}

			res += max<ll>(0, time - dt);

			cout << res << '\n';

		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 496 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 2 ms 364 KB Output is correct
38 Correct 2 ms 364 KB Output is correct
39 Correct 2 ms 364 KB Output is correct
40 Correct 2 ms 364 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 4692 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 492 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 496 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 2 ms 364 KB Output is correct
38 Correct 2 ms 364 KB Output is correct
39 Correct 2 ms 364 KB Output is correct
40 Correct 2 ms 364 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
42 Runtime error 65 ms 4692 KB Execution failed because the return code was nonzero
43 Halted 0 ms 0 KB -