Submission #1030627

# Submission time Handle Problem Language Result Execution time Memory
1030627 2024-07-22T07:51:59 Z 김은성(#10955) Bitaro, who Leaps through Time (JOI19_timeleap) C++17
0 / 100
3000 ms 14676 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;
            tb += b;
                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);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 14676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -