Submission #1075268

#TimeUsernameProblemLanguageResultExecution timeMemory
1075268raduvSimple (info1cup19_simple)C++17
30 / 100
163 ms34008 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 200'001; const long long INF = (1LL << 60); struct aintnode{ long long minimp, minpar, maximp, maxpar; }aint[4 * MAXN + 1]; long long lazy[4 * MAXN + 1]; long long minipar, maximpar; static inline void nodeupd(int node, int val){ if(aint[node].minpar != INF){ aint[node].minpar += val; aint[node].maxpar += val; } if(aint[node].minimp != INF){ aint[node].minimp += val; aint[node].maximp += val; } if(val % 2 == 1){ swap(aint[node].minimp, aint[node].minpar); swap(aint[node].maximp, aint[node].maxpar); } } static inline void propagate(int node){ if(lazy[node] > 0){ lazy[2 * node] += lazy[node]; nodeupd(2 * node, lazy[node]); lazy[2 * node + 1] += lazy[node]; nodeupd(2 * node + 1, lazy[node]); lazy[node] = 0; } } void build(int node, int st, int dr){ if(st == dr){ int x; scanf("%d", &x); if(x % 2 == 0) aint[node].minpar = aint[node].maxpar = x; else aint[node].minimp = aint[node].maximp = x; } else{ int mij = (st + dr) / 2; build(2 * node, st, mij); build(2 * node + 1, mij + 1, dr); aint[node].minpar = min(aint[2 * node].minpar, aint[2 * node + 1].minpar); aint[node].minimp = min(aint[2 * node].minimp, aint[2 * node + 1].minimp); aint[node].maxpar = max(aint[2 * node].maxpar, aint[2 * node + 1].maxpar); aint[node].maximp = max(aint[2 * node].maximp, aint[2 * node + 1].maximp); } } void update(int node, int st, int dr, int l, int r, int val){ if( l <= st && dr <= r ){ lazy[node] += val; nodeupd(node, val); } else{ propagate(node); int mij = (st + dr) / 2; if( l <= mij ) update(2 * node, st, mij, l, r, val); if(r > mij) update(2 * node + 1, mij + 1, dr, l, r, val); aint[node].minpar = min(aint[2 * node].minpar, aint[2 * node + 1].minpar); aint[node].minimp = min(aint[2 * node].minimp, aint[2 * node + 1].minimp); aint[node].maxpar = max(aint[2 * node].maxpar, aint[2 * node + 1].maxpar); aint[node].maximp = max(aint[2 * node].maximp, aint[2 * node + 1].maximp); } } void query(int node, int st, int dr, int l, int r){ if( l <= st && dr <= r ){ minipar = min(minipar, aint[node].minpar); maximpar = max(maximpar, aint[node].maximp); } else{ propagate(node); int mij = (st + dr) / 2; if( l <= mij ) query(2 * node, st, mij, l, r); if(r > mij) query(2 * node + 1, mij + 1, dr, l, r); } } int main() { int n, q, i, l, r, val, tip; scanf("%d", &n); for( i = 0; i <= 4 * MAXN; i++ ){ aint[i].minimp = aint[i].minpar = INF; aint[i].maximp = aint[i].maxpar = -1; } build(1, 1, n); scanf("%d", &q); for( i = 0; i < q; i++ ){ scanf("%d%d%d", &tip, &l, &r); if(tip == 0){ scanf("%d", &val); update(1, 1, n, l, r, val); } else{ minipar = INF; maximpar = -1; query(1, 1, n, l, r); printf("%lld %lld\n", (minipar == INF ? -1 : minipar), maximpar); } } return 0; }

Compilation message (stderr)

subway.cpp: In function 'void build(int, int, int)':
subway.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d", &x);
      |     ~~~~~^~~~~~~~~~
subway.cpp: In function 'int main()':
subway.cpp:86:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
subway.cpp:94:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |   scanf("%d", &q);
      |   ~~~~~^~~~~~~~~~
subway.cpp:96:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |     scanf("%d%d%d", &tip, &l, &r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
subway.cpp:98:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |       scanf("%d", &val);
      |       ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...