Submission #668257

#TimeUsernameProblemLanguageResultExecution timeMemory
668257600MihneaCollecting Mushrooms (NOI18_collectmushrooms)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main() { #ifdef ONPC freopen ("input.txt", "r", stdin); #endif // ONPC #ifndef ONPC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif // ONPC int n, m, r, need; cin >> n >> m >> r >> need; vector<pair<int, int>> mus, spr; for (int i = 0; i < n; i++) { string s; cin >> s; assert((int) s.size() == m); for (int j = 0; j < m; j++) { char ch = s[j]; if (ch == '.') { continue; } if (ch == 'S') { spr.push_back({i, j + 1}); continue; } if (ch == 'M') { mus.push_back({i, j + 1}); continue; } assert(0); } } vector<int> t(m + 1, 0); auto add = [&] (int i, int x) { while (i <= m) { t[i] += x; i += i & (-i); } }; auto get = [&] (int i) { int sol = 0; while (i) { sol += t[i]; i -= i & (-i); } return sol; }; int sol = 0; sort(mus.begin(), mus.end()); sort(spr.begin(), spr.end()); int p1 = 0, p2 = 0; for (auto &it : mus) { while (p1 < (int) spr.size() && spr[p1].first <= it.first + r) { add(spr[p1].second, +1); p1++; } while (p2 < (int) spr.size() && spr[p2].first < it.first - r) { add(spr[p2].second, -1); p2++; } sol += (get(high) - get(low - 1) >= need); } cout << sol << "\n"; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:79:17: error: 'high' was not declared in this scope
   79 |     sol += (get(high) - get(low - 1) >= need);
      |                 ^~~~
mushrooms.cpp:79:29: error: 'low' was not declared in this scope; did you mean 'pow'?
   79 |     sol += (get(high) - get(low - 1) >= need);
      |                             ^~~
      |                             pow