Submission #630904

# Submission time Handle Problem Language Result Execution time Memory
630904 2022-08-17T10:20:55 Z valerikk Bitaro, who Leaps through Time (JOI19_timeleap) C++17
0 / 100
3000 ms 8068 KB
#include <bits/stdc++.h>

using namespace std;

int solve(vector<int> l, vector<int> r) {
	int n = l.size();
	int t = 0;
	int res = 0;
	for (int i = 0; i < n; ++i) {
		if (t > r[i]) {
			res += t - r[i];
			t = r[i];
		}
		if (t < l[i]) {
			t = l[i];
		}
		++t;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<int> l(n), r(n);
	for (int i = 0; i < n - 1; ++i) {
		cin >> l[i] >> r[i];
		--r[i];
	}
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			int p, s, e;
			cin >> p >> s >> e;
			--p, --e;
			l[p] = s, r[p] = e;
		}
		if (t == 2) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			--a, --c;
			if (a == c) {
				cout << max(0, b - d) << "\n";
			} else {
				vector<int> cl, cr;
				cl.push_back(b - 1);
				cr.push_back(b - 1);
				if (a < c) {
					for (int i = a; i < c; ++i) {
						cl.push_back(l[i]);
						cr.push_back(r[i]);
					}
				} else {
					for (int i = a - 1; i >= c; --i) {
						cl.push_back(l[i]);
						cr.push_back(r[i]);
					}
				}
				cl.push_back(d);
				cr.push_back(d);
				cout << solve(cl, cr) << "\n";
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 3 ms 340 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3051 ms 8068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 3 ms 340 KB Output isn't correct
12 Halted 0 ms 0 KB -