제출 #321649

#제출 시각아이디문제언어결과실행 시간메모리
321649Kevin_Zhang_TWFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
529 ms57068 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define pb emplace_back //#undef KEV #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); } template <class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l) == r], ++l; } #else #define DE(...) 0 #define debug(...) 0 #endif template <class T> bool chmin(T &a, T b) { return b < a ? (a = b, true) : false; } template <class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; } const int MAX_N = 200010; const ll inf = 1ll << 58; #define int ll int n, q, s, t; struct node { ll lh, rh, sum, tg; node(ll v) : lh(v), rh(v), sum(0), tg(0) {} node(node a, node b) : lh(a.lh), rh(b.rh), sum(a.sum + b.sum + (a.rh < b.lh ? (a.rh - b.lh) * s : (a.rh - b.lh) * t)), tg(0) {} node() : lh(0), rh(0), sum(0), tg(0) {} void operator += (int val) { lh += val, rh += val, tg += val; } void dbg() { //DE(lh, rh, sum); } }val[MAX_N << 3]; int a[MAX_N]; void push(int i, int l, int r) { if (l == r || val[i].tg == 0) return; int m = l + r >> 1; val[i<<1] += val[i].tg, val[i<<1|1] += val[i].tg; val[i].tg = 0; } void update(int i, int l, int r) { if (l == r) return; push(i, l, r); val[i] = node(val[i<<1], val[i<<1|1]); } void modify(int ml, int mr, int nv, int l = 0, int r = n, int i = 1) { if (ml > r || mr < l) return; assert(l <= r); push(i, l, r); if (ml <= l && mr >= r) { val[i] += nv; return; } int m = l + r >> 1; modify(ml, mr, nv, l, m, i<<1); modify(ml, mr, nv,m+1,r, i<<1|1); val[i] = node(val[i<<1], val[i<<1|1]); DE(l, r); val[i].dbg(); } ll qry() { val[1].dbg(); //cerr << '\n'; return val[1].sum; } void init() { debug(a, a+n+1); for (int i = 0;i <= n;++i) modify(i, i, a[i]); cerr << "Init done\n"; } void solve() { while (q--) { int l, r, x; cin >> l >> r >> x; modify(l, r, x); cout << qry() << '\n'; } } int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> q >> s >> t; for (int i = 0;i <= n;++i) cin >> a[i]; init(); solve(); }

컴파일 시 표준 에러 (stderr) 메시지

foehn_phenomena.cpp: In function 'void push(ll, ll, ll)':
foehn_phenomena.cpp:47:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   47 |  int m = l + r >> 1;
      |          ~~^~~
foehn_phenomena.cpp:47:6: warning: unused variable 'm' [-Wunused-variable]
   47 |  int m = l + r >> 1;
      |      ^
foehn_phenomena.cpp: In function 'void modify(ll, ll, ll, ll, ll, ll)':
foehn_phenomena.cpp:65:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   65 |  int m = l + r >> 1;
      |          ~~^~~
foehn_phenomena.cpp:14:17: warning: statement has no effect [-Wunused-value]
   14 | #define DE(...) 0
      |                 ^
foehn_phenomena.cpp:71:2: note: in expansion of macro 'DE'
   71 |  DE(l, r);
      |  ^~
foehn_phenomena.cpp: In function 'void init()':
foehn_phenomena.cpp:15:20: warning: statement has no effect [-Wunused-value]
   15 | #define debug(...) 0
      |                    ^
foehn_phenomena.cpp:80:2: note: in expansion of macro 'debug'
   80 |  debug(a, a+n+1);
      |  ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...