# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
370399 | 2021-02-24T01:33:23 Z | Mamnoon_Siam | Bitaro, who Leaps through Time (JOI19_timeleap) | C++17 | 3 ms | 492 KB |
#include <bits/stdc++.h> using namespace std; /* sorry, this is the bare minimum :'( */ using ll = long long; using ii = pair<int, int>; using vi = vector<int>; #define all(v) begin(v), end(v) #define sz(v) (int)(v).size() #define fi first #define se second string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif const int N = 1005; int n, q; int L[N], R[N]; ll query(int i, int j, int t1, int t2) { int inc = j < i ? -1 : 1; int del = j < i ? -1 : 0; ll ans = 0; while(i != j) { if(t1 > R[i+del]-1) { ans += t1 - (R[i+del] - 1); t1 = R[i+del]-1; } else if(t1 < L[i+del]) { t1 = L[i+del]; } ++t1; debug(t1); i += inc; } ans += max(0, t1 - t2); return ans; } int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d", &n, &q); for(int i = 1; i < n; ++i) { scanf("%d %d", &L[i], &R[i]); } while(q--) { int op; scanf("%d", &op); if(op == 1) { int p; scanf("%d", &p); scanf("%d %d", &L[p], &R[p]); } else { int i, j, t1, t2; scanf("%d %d %d %d", &i, &t1, &j, &t2); printf("%lld\n", query(i, j, t1, t2)); } } return 0; }
Compilation message
# | 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 | 384 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 | 3 ms | 364 KB | Output is correct |
13 | Correct | 2 ms | 364 KB | Output is correct |
14 | Correct | 2 ms | 364 KB | Output is correct |
15 | Correct | 2 ms | 364 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 364 KB | Output is correct |
18 | Correct | 3 ms | 364 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 364 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 | 3 ms | 364 KB | Output is correct |
26 | Correct | 2 ms | 364 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 364 KB | Output is correct |
29 | Correct | 3 ms | 364 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
31 | Correct | 2 ms | 372 KB | Output is correct |
32 | Correct | 2 ms | 492 KB | Output is correct |
33 | Correct | 2 ms | 364 KB | Output is correct |
34 | Correct | 2 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 | Execution timed out | 2 ms | 364 KB | Time limit exceeded (wall clock) |
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 | 384 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 | 3 ms | 364 KB | Output is correct |
13 | Correct | 2 ms | 364 KB | Output is correct |
14 | Correct | 2 ms | 364 KB | Output is correct |
15 | Correct | 2 ms | 364 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 364 KB | Output is correct |
18 | Correct | 3 ms | 364 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 364 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 | 3 ms | 364 KB | Output is correct |
26 | Correct | 2 ms | 364 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 364 KB | Output is correct |
29 | Correct | 3 ms | 364 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
31 | Correct | 2 ms | 372 KB | Output is correct |
32 | Correct | 2 ms | 492 KB | Output is correct |
33 | Correct | 2 ms | 364 KB | Output is correct |
34 | Correct | 2 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 | Execution timed out | 2 ms | 364 KB | Time limit exceeded (wall clock) |
43 | Halted | 0 ms | 0 KB | - |