제출 #1168009

#제출 시각아이디문제언어결과실행 시간메모리
1168009zh_hCollecting Mushrooms (NOI18_collectmushrooms)C++20
0 / 100
2096 ms5972 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; int main() { int R, C, D, K; cin >> R >> C >> D >> K; vector<vector<char>> grid(R, vector<char>(C)); vector<pair<int, int>> splinter; for (int i = 0; i < R; i ++) { for (int j = 0; j < C; j ++) { char temp; cin >> temp; grid[i][j] = temp; if (temp == 'S') { splinter.pb({i, j}); } } } vector<vector<int>> mushroom(R, vector<int>(C, 0)); int harvestable_mushroom = 0; for (int z = 0; z < splinter.size(); z ++) { int x = splinter[z].first, y = splinter[z].second; int first_row = max(0, x-D), last_row = min(R-1, x+D); int first_col = max(0, y-D), last_col = min(C-1, y+D); // cout << first_row << " " << for (int i = first_row; i <= last_row; i ++) { for (int j = first_col; j <= last_col; j ++) { if (grid[i][j] == 'M') { mushroom[i][j]++; } if (mushroom[i][j] >= K) { grid[i][j] == '.'; harvestable_mushroom ++; } } } } cout << harvestable_mushroom << endl; } // 5 5 1 1 // ....M // .M... // ..S.. // .S... // ...M.
#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...