Submission #110560

#TimeUsernameProblemLanguageResultExecution timeMemory
110560AngusRitossaBitaro, who Leaps through Time (JOI19_timeleap)C++14
4 / 100
3021 ms10836 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, q; int l[300010], r[300010]; #undef int int main() { #define int long long scanf("%lld%lld", &n, &q); for (int i = 1; i < n; i++) { scanf("%lld%lld", &l[i], &r[i]); r[i]--; } for (int f = 0; f < q; f++) { int t; scanf("%lld", &t); if (t == 1) { int p, s, e; scanf("%lld%lld%lld", &p, &s, &e); l[p] = s, r[p] = e; r[p]--; } else { int a, t1, b, t2; scanf("%lld%lld%lld%lld", &a, &t1, &b, &t2); if (a == b) { if (t1 <= t2) printf("0\n"); else printf("%lld\n", t1-t2); } else if (a < b) { int ans = 0; for (int i = a; i < b; i++) { if (t1 < l[i]) t1 = l[i]; if (t1 > r[i]) { ans += t1-r[i]; t1 = r[i]; } t1++; } ans += max(0ll, t1-t2); printf("%lld\n", ans); } else { int ans = 0; for (int i = a-1; i >= b; i--) { if (t1 < l[i]) t1 = l[i]; if (t1 > r[i]) { ans += t1-r[i]; t1 = r[i]; } t1++; } ans += max(0ll, t1-t2); printf("%lld\n", ans); } } } }

Compilation message (stderr)

timeleap.cpp: In function 'int main()':
timeleap.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
timeleap.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &l[i], &r[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &t);
   ~~~~~^~~~~~~~~~~~
timeleap.cpp:23:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld%lld%lld", &p, &s, &e);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:30:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld%lld%lld%lld", &a, &t1, &b, &t2);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...