Submission #1115311

#TimeUsernameProblemLanguageResultExecution timeMemory
1115311staszic_ojuzDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms336 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...