Submission #370399

#TimeUsernameProblemLanguageResultExecution timeMemory
370399Mamnoon_SiamBitaro, who Leaps through Time (JOI19_timeleap)C++17
4 / 100
3 ms492 KiB
#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 (stderr)

timeleap.cpp: In function 'll query(int, int, int, int)':
timeleap.cpp:56:20: warning: statement has no effect [-Wunused-value]
   56 | #define debug(...) 42
      |                    ^~
timeleap.cpp:76:5: note: in expansion of macro 'debug'
   76 |     debug(t1);
      |     ^~~~~
timeleap.cpp: In function 'int main(int, const char**)':
timeleap.cpp:88:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   88 |   scanf("%d %d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~~
timeleap.cpp:90:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   90 |     scanf("%d %d", &L[i], &R[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:93:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   93 |     int op; scanf("%d", &op);
      |             ~~~~~^~~~~~~~~~~
timeleap.cpp:95:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   95 |       int p; scanf("%d", &p);
      |              ~~~~~^~~~~~~~~~
timeleap.cpp:96:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   96 |       scanf("%d %d", &L[p], &R[p]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
timeleap.cpp:99:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   99 |       scanf("%d %d %d %d", &i, &t1, &j, &t2);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...