Submission #742812

#TimeUsernameProblemLanguageResultExecution timeMemory
742812FnzxCollecting Mushrooms (NOI18_collectmushrooms)C++17
79 / 100
21 ms10180 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; using pii = pair<ll , ll> ; using i3 = tuple<ll , ll , ll> ; const int N = 1001; const int MOD = 1e9+7 ; int n , m , d , k , ans; int G[N][N] ; vector<pii> mushroom ; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> d >> k ; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ char x ; cin >> x ; if(x == 'S'){ G[i][j]++ ; } else if(x == 'M'){ mushroom.push_back({i , j}); } } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ G[i][j] += G[i-1][j] + G[i][j-1] - G[i-1][j-1] ; } } for(int i=0;i<mushroom.size();i++){ int uy = mushroom[i].first , ux = mushroom[i].second ; int x1 = max(1 , ux - d) , y1 = max(1 , uy - d) ; int x2 = min(m , ux + d) , y2 = min(n , uy + d) ; int sum = G[y2][x2] - G[y1 - 1][x2] - G[y2][x1 - 1] + G[y1 - 1][x1 - 1] ; if(sum >= k){ ans++; } } cout << ans ; }

Compilation message (stderr)

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