Submission #1269525

#TimeUsernameProblemLanguageResultExecution timeMemory
1269525ducdevCollecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
16 ms16988 KiB
// Author: 4uckd3v - Nguyen Cao Duc #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 1e6; const int MOD = 1e9 + 7; int m, n, d, k; vector<vector<char>> a; vector<vector<int>> pref; void updateRange(int i, int j) { int x = max(1, i - d), y = max(1, j - d); int u = min(m, i + d), v = min(n, j + d); pref[x][y]++, pref[u + 1][v + 1]++; pref[u + 1][y]--, pref[x][v + 1]--; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen("MAIN.INP", "r")) { freopen("MAIN.INP", "r", stdin); freopen("MAIN.OUT", "w", stdout); }; cin >> m >> n >> d >> k; a.resize(m + 5, vector<char>(n + 5)); pref.resize(m + 5, vector<int>(n + 5, 0)); for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; if (a[i][j] == 'S') updateRange(i, j); }; }; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { pref[i][j] += pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1]; }; }; int res = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if (a[i][j] == 'M' && pref[i][j] >= k) res++; }; }; cout << res << '\n'; };

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen("MAIN.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen("MAIN.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...