Submission #951591

#TimeUsernameProblemLanguageResultExecution timeMemory
951591PringFish 2 (JOI22_fish2)C++17
13 / 100
4051 ms9460 KiB
#include <bits/stdc++.h> using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define int long long #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) typedef pair<int, int> pii; const int MXN = 100005; int n, q, a[MXN]; struct SMG { #define mid ((l + r) >> 1) pii val[MXN * 4]; void build(int id, int l, int r) { if (l + 1 == r) { val[id] = mp(a[l], l); return; } build(id * 2 + 1, l, mid); build(id * 2 + 2, mid, r); val[id] = max(val[id * 2 + 1], val[id * 2 + 2]); } void modify(int id, int l, int r, int p) { if (l + 1 == r) { val[id] = mp(a[l], l); return; } if (p < mid) modify(id * 2 + 1, l, mid, p); else modify(id * 2 + 2, mid, r, p); val[id] = max(val[id * 2 + 1], val[id * 2 + 2]); } pii query(int id, int l, int r, int _l, int _r) { if (_r <= l || r <= _l) return mp(0LL, -1LL); if (_l <= l && r <= _r) return val[id]; return max(query(id * 2 + 1, l, mid, _l, _r), query(id * 2 + 2, mid, r, _l, _r)); } } smg; struct BIT { int n, val[MXN]; void init(int _n) { n = _n; fill(val + 1, val + n + 1, 0); } void modify(int id, int v) { for (id++; id <= n; id += (id & -id)) val[id] += v; } int query(int id) { int ans = 0; for (; id > 0; id -= (id & -id)) ans += val[id]; return ans; } int query(int l, int r) { return query(r) - query(l); } } B; int calc(int l, int r) { if (l >= r) return 0; auto [big, rt] = smg.query(0, 0, n, l, r); int ans = 1; debug(l, r, rt, B.query(l, rt), B.query(rt + 1, r)); if (B.query(l, rt) >= big) ans += calc(l, rt); if (B.query(rt + 1, r) >= big) ans += calc(rt + 1, r); return ans; } void miku() { int t, x, y; cin >> n; FOR(i, 0, n) cin >> a[i]; smg.build(0, 0, n); B.init(n); FOR(i, 0, n) B.modify(i, a[i]); FOR(i, 0, n) debug(i, B.query(i, i + 1)); cin >> q; FOR(i, 0, q) { cin >> t >> x >> y; if (t == 1) { x--; B.modify(x, y - a[x]); a[x] = y; smg.modify(0, 0, n, x); } else { cout << calc(--x, y) << '\n'; } } } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(cin.failbit); miku(); return 0; }

Compilation message (stderr)

fish2.cpp: In function 'long long int calc(long long int, long long int)':
fish2.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
fish2.cpp:75:5: note: in expansion of macro 'debug'
   75 |     debug(l, r, rt, B.query(l, rt), B.query(rt + 1, r));
      |     ^~~~~
fish2.cpp: In function 'void miku()':
fish2.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
fish2.cpp:88:18: note: in expansion of macro 'debug'
   88 |     FOR(i, 0, n) debug(i, B.query(i, i + 1));
      |                  ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...