답안 #1095944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095944 2024-10-03T12:24:32 Z Lakshya108 Dango Maker (JOI18_dango_maker) C++14
0 / 100
0 ms 348 KB
#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});
            }
            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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -