Submission #1005969

#TimeUsernameProblemLanguageResultExecution timeMemory
1005969makanhuliaCollecting Mushrooms (NOI18_collectmushrooms)C++17
9 / 100
8 ms9180 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m, d, s; cin >> n >> m >> d >> s; string grid[n + 1]; for ( int i = 0; i < n; i++) cin >> grid[i]; vector < int > a ( n + 5), b ( n + 5); vector < pair < int, int > > tanaman; for ( int i = 0; i < n; i++){ for ( int j = 0; j < m; j++){ if ( grid[i][j] == 'M' ){ tanaman.push_back({i, j}); } if ( grid[i][j] == 'S' ){ int xmn = max ( 0ll, i - d); int xmx = min ( n, i + d ); a[xmn]++; a[xmx + 1]--; int ymn = max ( 0ll, j - d); int ymx = min ( m, j + d); b[ymn]++; b[xmx + 1]--; } } } for ( int i = 1; i < n; i++) a[i] += a[i - 1]; for ( int i = 1; i < m; i++) a[i] += b[i - 1]; int cnt = 0; for ( int i = 0; i < tanaman.size(); i++){ int x = tanaman[i].first, y = tanaman[i].second; int mx = max ( a[x], b[y] ); if ( mx >= s ) cnt++; } cout << cnt << endl; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:34:21: warning: unused variable 'ymx' [-Wunused-variable]
   34 |                 int ymx = min ( m, j + d);
      |                     ^~~
mushrooms.cpp:48:24: 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]
   48 |     for ( int i = 0; i < tanaman.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...