Submission #244261

#TimeUsernameProblemLanguageResultExecution timeMemory
244261arnold518Collecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
50 ms7188 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int N, M, D, K; vector<vector<char>> A; vector<vector<int>> S; int query(int y1, int x1, int y2, int x2) { y1=max(y1, 1); x1=max(x1, 1); y2=min(y2, N); x2=min(x2, M); return S[y2][x2]-S[y1-1][x2]-S[y2][x1-1]+S[y1-1][x1-1]; } int main() { int i, j; scanf("%d%d%d%d", &N, &M, &D, &K); A=vector<vector<char>>(N+1, vector<char>(M+1)); S=vector<vector<int>>(N+1, vector<int>(M+1)); for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf(" %c", &A[i][j]); for(i=1; i<=N; i++) { for(j=1; j<=M; j++) { S[i][j]=S[i-1][j]+S[i][j-1]-S[i-1][j-1]; if(A[i][j]=='S') S[i][j]++; } } int ans=0; for(i=1; i<=N; i++) for(j=1; j<=M; j++) { if(A[i][j]=='M') { if(query(i-D, j-D, i+D, j+D)>=K) ans++; } } printf("%d\n", ans); }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &N, &M, &D, &K);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:26:47: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf(" %c", &A[i][j]);
                                          ~~~~~^~~~~~~~~~~~~~~~~
#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...