답안 #1030629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030629 2024-07-22T07:53:10 Z 김은성(#10955) Bitaro, who Leaps through Time (JOI19_timeleap) C++17
4 / 100
3000 ms 8896 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s[300009], e[300009], s2[300009], e2[300009];
int main(){
    int n, q,i, type, a, b;
    ll ta, tb;
    scanf("%d %d", &n, &q);
    for(i=1; i<n; i++){
        scanf("%lld %lld", &s[i], &e[i]);
        s2[i] = s[i] + i;
        e2[i] = e[i] + i-1;
        s[i] -= i;
        e[i] -= i+1;
    }
    while(q--){
        scanf("%d", &type);
        if(type==1){
            scanf("%d %lld %lld", &i, &ta, &tb);
            s[i] = ta - i;
            e[i] = tb - i - 1;
            s2[i] = ta + i;
            e2[i] = tb + i - 1;
        }
        else{
            scanf("%d %lld %d %lld", &a, &ta, &b, &tb);
            if(a<b){
                ta -= a;
                tb -= b;
                ll cur = ta, ans = 0;
                for(i=a; i<b; i++){
                    if(cur < s[i])
                        cur = s[i];
                    else if(cur > e[i]){
                        ans += cur - e[i];
                        cur = e[i];
                    }
                }
                if(cur > tb)
                    ans += cur - tb;
                printf("%lld\n", ans);
            }
            else{
                ta += a-1;
                tb += b-1;
                ll cur = ta, ans = 0;
                for(i=a-1; i>=b; i--){
                    if(cur < s2[i])
                        cur = s2[i];
                    else if(cur > e2[i]){
                        ans += cur - e2[i];
                        cur = e2[i];
                    }
                }
                if(cur > tb)
                    ans += cur - tb;
                printf("%lld\n", ans);
            }
        }
    }
    return 0;
}

Compilation message

timeleap.cpp: In function 'int main()':
timeleap.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
timeleap.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%lld %lld", &s[i], &e[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d", &type);
      |         ~~~~~^~~~~~~~~~~~~
timeleap.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |             scanf("%d %lld %lld", &i, &ta, &tb);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |             scanf("%d %lld %d %lld", &a, &ta, &b, &tb);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 484 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 496 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3068 ms 8896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 484 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 496 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Execution timed out 3068 ms 8896 KB Time limit exceeded
43 Halted 0 ms 0 KB -