Submission #1005982

#TimeUsernameProblemLanguageResultExecution timeMemory
1005982makanhuliaCollecting Mushrooms (NOI18_collectmushrooms)C++17
100 / 100
26 ms36048 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int r, c, d, s, jum; vector<pair<int, int>> v; signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin >> r >> c >> d >> s; char arr[r + 5][c + 5]; int pref[r + 5][c + 5]; for(int i = 1; i <= r; i++) { for(int j = 1; j <= c; j++) { cin >> arr[i][j]; if(arr[i][j] == 'M') { v.push_back({i, j}); } } } for(int i = 1; i <= r; i++) { for(int j = 1; j <= c; j++) { if(arr[i][j] == 'S') { pref[i][j] = pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1] + 1; } else { pref[i][j] = pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1]; } } } for(int i = 0; i < v.size(); i++) { int a = v[i].first, b = v[i].second; int lr, lc, hr, hc; lr = max(0ll, a - d - 1); lc = max(0ll, b - d - 1); hr = min(r, a + d); hc = min(c, b + d); int funi = pref[hr][hc] - pref[lr][hc] - pref[hr][lc] + pref[lr][lc]; if(funi >= s) { jum++; } } cout << jum << "\n"; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:28:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for(int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
#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...