Submission #931097

#TimeUsernameProblemLanguageResultExecution timeMemory
931097PringA Huge Tower (CEOI10_tower)C++14
30 / 100
321 ms28792 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3","unroll-loops") #pragma GCC target("avx2","popcnt") using namespace std; #ifdef MIKU #define debug(x...) cout << '[' << #x << "] : ", dout(x) void dout() { cout << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define ll long long #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++) typedef pair<int, int> pii; const int MXN = 1000005, mod = 100000009; int n, d, a[MXN]; int ADD(int a, int b) { a += b; a -= (a >= mod ? mod : 0); return a; } int MUL(int a, int b) { return (ll) a * b % mod; } struct SMG { int val[MXN * 4], tag[MXN * 4]; void add_tag(int id, int t) { val[id] = MUL(val[id], t); tag[id] = MUL(tag[id], t); } void push(int id) { if (tag[id] == 1) return; add_tag(id * 2 + 1, tag[id]); add_tag(id * 2 + 2, tag[id]); tag[id] = 1; } void pull(int id) { val[id] = ADD(val[id * 2 + 1], val[id * 2 + 2]); } void build(int id, int l, int r) { val[id] = r - l; tag[id] = 1; if (l + 1 == r) return; int mid = (l + r) >> 1; build(id * 2 + 1, l, mid); build(id * 2 + 2, mid, r); } void modify(int id, int l, int r, int _l, int _r, int v) { if (_r <= l || r <= _l) return; if (_l <= l && r <= _r) { add_tag(id, v); return; } int mid = (l + r) >> 1; push(id); modify(id * 2 + 1, l, mid, _l, _r, v); modify(id * 2 + 2, mid, r, _l, _r, v); pull(id); } int query(int id, int l, int r, int _l, int _r) { if (_r <= l || r <= _l) return 0; if (_l <= l && r <= _r) return val[id]; int mid = (l + r) >> 1; push(id); return ADD(query(id * 2 + 1, l, mid, _l, _r), query(id * 2 + 2, mid, r, _l, _r)); } void DFS(int id, int l, int r) { if (l + 1 == r) { cout << val[id] << ' '; return; } int mid = (l + r) >> 1; DFS(id * 2 + 1, l, mid); DFS(id * 2 + 2, mid, r); } } smg; void miku() { cin >> n >> d; FOR(i, 0, n) cin >> a[i]; sort(a, a + n); int p = 0; smg.build(0, 0, n); FOR(i, 1, n) { while (a[p] + d < a[i]) p++; smg.modify(0, 0, n, i, i + 1, smg.query(0, 0, n, p, i)); smg.modify(0, 0, n, 0, p, i - p + 1); smg.modify(0, 0, n, p, i, i - p); // smg.DFS(0, 0, n); // cout << '\n'; } cout << smg.val[0] << '\n'; } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(iostream::failbit); miku(); return 0; }

Compilation message (stderr)

tower.cpp: In function 'void miku()':
tower.cpp:19:38: warning: unused variable 'Z' [-Wunused-variable]
   19 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
tower.cpp:90:5: note: in expansion of macro 'FOR'
   90 |     FOR(i, 0, n) cin >> a[i];
      |     ^~~
tower.cpp:19:38: warning: unused variable 'Z' [-Wunused-variable]
   19 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
tower.cpp:94:5: note: in expansion of macro 'FOR'
   94 |     FOR(i, 1, n) {
      |     ^~~
#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...
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...