Submission #1095945

#TimeUsernameProblemLanguageResultExecution timeMemory
1095945Lakshya108Dango Maker (JOI18_dango_maker)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; bool check_pattern_vertical(vector<string> &grid, int i, int j, int n) { return (i + 2 < n && grid[i][j] == 'R' && grid[i+1][j] == 'G' && grid[i+2][j] == 'W'); } bool check_pattern_horizontal(vector<string> &grid, int i, int j, int m) { return (j + 2 < m && grid[i][j] == 'R' && grid[i][j+1] == 'G' && grid[i][j+2] == 'W'); } void solve() { int n, m; cin >> n >> m; vector<string> grid(n); for (int i = 0; i < n; i++) { cin >> grid[i]; } int ans = 0; vector<pair<int, int>> to_mark; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (check_pattern_vertical(grid, i, j, n)) { ans++; to_mark.push_back({i, j}); to_mark.push_back({i+1, j}); to_mark.push_back({i+2, j}); } else if (check_pattern_horizontal(grid, i, j, m)) { ans++; to_mark.push_back({i, j}); to_mark.push_back({i, j+1}); to_mark.push_back({i, j+2}); } } } // After counting all patterns, mark the grid for (auto &pos : to_mark) { grid[pos.first][pos.second] = 'P'; // Mark processed cells } // Output the total number of `RGW` grids found cout << ans; } int main() { solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...