답안 #706755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706755 2023-03-07T16:48:43 Z esomer Dango Maker (JOI18_dango_maker) C++17
0 / 100
0 ms 212 KB
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
const int MOD = 1e9 + 7;


//~ void calc(int i, int j, vector<vector<char>>& table, vector<vector<vector<int>>>& v, vector<vector<bool>>& done){
	//~ if(i < n - 2 && table[i + 1][j] == 'G' && table[i+2][j] == 'W' && done[i][j] == 0 && done[i+1][j] == 0 && done[i+2][j] == 0){
	//~ }else if(j < m - 2 && table[i][j + 1] == 'G' && table[i][j + 2] == 'W' && done[i][j] == 0 && done[i][j+1] == 0 && done[i][j+2] == 0){
		//~ int cnt = 0;
		
		//~ else{
			//~ ans++;
			//~ done[i][j] = 1;
			//~ done[i][j+1] = 1;
			//~ done[i][j+2] = 1;
		//~ }
	//~ }
//~ }

void solve(){
	int n, m; cin >> n >> m;
	vector<vector<char>> table(n, vector<char>(m));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++) cin >> table[i][j];
	}
	vector<vector<int>> v(n, vector<int>(m, 0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(table[i][j] != 'R') continue;
			if(i < n - 2){
				if(table[i + 1][j] == 'G' && table[i+2][j] == 'W'){
					v[i+1][j]++;
					v[i+2][j]++;
				}
			}
			if(j < m - 2){
				if(table[i][j + 1] == 'G' && table[i][j + 2] == 'W'){
					v[i][j + 1]++;
					v[i][j + 2]++;
				}
			}
		}
	}
	vector<vector<bool>> done(n, vector<bool>(m, 0));
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(table[i][j] == 'R' && done[i][j] == 0){
				if(j < m - 2 && table[i][j + 1] == 'G' && table[i][j + 2] == 'W' && done[i][j] == 0 && done[i][j+1] == 0 && done[i][j+2] == 0){
					ans++;
					done[i][j] = 1; done[i][j+1] = 1; done[i][j+2] = 1;
				}else if(i < n - 2 && table[i + 1][j] == 'G' && table[i+2][j] == 'W' && done[i][j] == 0 && done[i+1][j] == 0 && done[i+2][j] == 0){
					if(v[i+1][j] == 2 && v[i+2][j] == 2){
						if(v[i+1][j-1] == 2){
							ans += 2;
							done[i+1][j] = 1; done[i+2][j] = 1; done[i][j] = 1;
							done[i+1][j-1] = 1; done[i+3][j-1] = 1; done[i+2][j-1] = 1;
						}
						else{
							ans += 2;
							done[i+1][j-1] = 1; done[i+1][j] = 1; done[i+1][j+1] = 1;
							done[i+2][j-2] = 1; done[i+2][j-1] = 1; done[i+2][j] = 1;
						}
					}else{
						ans++;
						done[i][j] = 1; done[i+1][j] = 1; done[i+2][j] = 1;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

    //~ int tt; cin >> tt;
    int tt = 1;
    for(int t = 1; t <= tt; t++){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -