답안 #1115311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115311 2024-11-20T10:22:32 Z staszic_ojuz Dango Maker (JOI18_dango_maker) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n, m; cin >> n >> m;
    vector<vector<char>> board(n, vector<char>(m));
    vector<vector<char>> boardr(m, vector<char>(n));
    for(int x = 0; x < n; x++){
        for(int y = 0; y < m; y++) {
            cin >> board[x][y];
            boardr[y][x] = board[x][y];
        }
    }
    // for(int x = 0; x < m; x++){
    //     for(int y = 0; y < n; y++) {
    //         cout << boardr[x][y] << " ";
    //     }
    //     cout << endl;
    // }

    ll mx = 0;
    vector<vector<bool>> vis(n, vector<bool>(m, false));
    // vector<vector<bool>> visr(m, vector<bool>(n, false));
    ll w = 0;
    for(int x = 0; x < n; x++) {
        for(int y = 0; y < m - 1; y++) {
            if(board[x][y] == 'R' && !vis[x][y]) {
                if(board[x][y + 1] == 'G' && !vis[x][y + 1] && board[x][y + 2] == 'W' && !vis[x][y + 2]) {
                    vis[x][y] = true;
                    vis[x][y+1] = true;
                    vis[x][y+2] = true;
                    w++;
                }
            } else if (board[x][y] == 'W' && !vis[x][y]) {
                if(board[x][y + 1] == 'G' && !vis[x][y + 1] && board[x][y + 2] == 'R' && !vis[x][y + 2]) {
                    vis[x][y] = true;
                    vis[x][y+1] = true;
                    vis[x][y+2] = true;
                    w++;
                }
            }
        }
    }
    //cout << w << " ";
    for(int x = 0; x < m; x++) {
        for(int y = 0; y < n - 1; y++) {
            //cout << boardr[x][y];
            if(boardr[x][y] == 'R' && !vis[y][x]) {
                if(boardr[x][y + 1] == 'G' && !vis[y + 1][x] && boardr[x][y + 2] == 'W' && !vis[y + 2][x]) {
                    vis[y][x] = true;
                    vis[y+1][x] = true;
                    vis[y+2][x] = true;
                    w++;
                }
            } else if (boardr[x][y] == 'W' && !vis[y][x]) {
                if(boardr[x][y + 1] == 'G' && !vis[y + 1][x] && boardr[x][y + 2] == 'R' && !vis[y + 2][x]) {
                    vis[y][x] = true;
                    vis[y+1][x] = true;
                    vis[y+2][x] = true;
                    w++;
                }
            }
        }
        //cout << endl;
    }
    //cout << w << " ";
    mx = w;
    w= 0;
    fill(vis.begin(), vis.end(), vector<bool>(m, false));
    for(int x = 0; x < m; x++) {
        for(int y = 0; y < n - 1; y++) {
            if(boardr[x][y] == 'R' && !vis[y][x]) {
                if(boardr[x][y + 1] == 'G' && !vis[y + 1][x] && boardr[x][y + 2] == 'W' && !vis[y + 2][x]) {
                    vis[y][x] = true;
                    vis[y+1][x] = true;
                    vis[y+2][x] = true;
                    w++;
                }
            } else if (boardr[x][y] == 'W' && !vis[y][x]) {
                if(boardr[x][y + 1] == 'G' && !vis[y + 1][x] && boardr[x][y + 2] == 'R' && !vis[y + 2][x]) {
                    vis[y][x] = true;
                    vis[y+1][x] = true;
                    vis[y+2][x] = true;
                    w++;
                }
            }
        }
    }
    for(int x = 0; x < n; x++) {
        for(int y = 0; y < m - 1; y++) {
            if(board[x][y] == 'R' && !vis[x][y]) {
                if(board[x][y + 1] == 'G' && !vis[x][y + 1] && board[x][y + 2] == 'W' && !vis[x][y + 2]) {
                    vis[x][y] = true;
                    vis[x][y+1] = true;
                    vis[x][y+2] = true;
                    w++;
                }
            } else if (board[x][y] == 'W' && !vis[x][y]) {
                if(board[x][y + 1] == 'G' && !vis[x][y + 1] && board[x][y + 2] == 'R' && !vis[x][y + 2]) {
                    vis[x][y] = true;
                    vis[x][y+1] = true;
                    vis[x][y+2] = true;
                    w++;
                }
            }
        }
    }
    //cout << w << " ";
    
    mx = max(w, mx);

    cout << mx;

    return 0;
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Halted 0 ms 0 KB -