Submission #118074

# Submission time Handle Problem Language Result Execution time Memory
118074 2019-06-18T06:39:24 Z 이온조(#2889) Bitaro, who Leaps through Time (JOI19_timeleap) C++14
4 / 100
3000 ms 3828 KB
#include <bits/stdc++.h>
using namespace std;

int L[300009], R[300009];

int main() {
    int N, Q; scanf("%d%d",&N,&Q);
    for(int i=1; i<N; i++) scanf("%d%d",&L[i],&R[i]);
    while(Q--) {
        int T; scanf("%d",&T);
        if(T == 1) {
            int P, S, E; scanf("%d%d%d",&P,&S,&E);
            L[P] = S, R[P] = E;
        }
        else {
            int A, B, C, D; scanf("%d%d%d%d",&A,&B,&C,&D);
            long long ans = 0;
            if(A < C) {
                for(int i=A; i<C; i++) {
                    if(B < L[i]) B = L[i];
                    if(B >= R[i]) ans += B - R[i] + 1, B = R[i] - 1;
                    ++B;
                }
                ans += max(0, B - D);
            }
            else {
                for(int i=A-1; i>=C; i--) {
                    if(B < L[i]) B = L[i];
                    if(B >= R[i]) ans += B - R[i] + 1, B = R[i] - 1;
                    ++B;
                }
                ans += max(0, B - D);
            }
            printf("%lld\n", ans);
        }
    }
    return 0;
}

Compilation message

timeleap.cpp: In function 'int main()':
timeleap.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int N, Q; scanf("%d%d",&N,&Q);
               ~~~~~^~~~~~~~~~~~~~
timeleap.cpp:8:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<N; i++) scanf("%d%d",&L[i],&R[i]);
                            ~~~~~^~~~~~~~~~~~~~~~~~~~
timeleap.cpp:10:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int T; scanf("%d",&T);
                ~~~~~^~~~~~~~~
timeleap.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int P, S, E; scanf("%d%d%d",&P,&S,&E);
                          ~~~~~^~~~~~~~~~~~~~~~~~~
timeleap.cpp:16:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int A, B, C, D; scanf("%d%d%d%d",&A,&B,&C,&D);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 356 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3088 ms 3828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 356 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Execution timed out 3088 ms 3828 KB Time limit exceeded
43 Halted 0 ms 0 KB -