답안 #255186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255186 2020-07-31T13:56:31 Z groeneprof Dango Maker (JOI18_dango_maker) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
#define P(x) do {if(debug) cout << x << endl;} while(false)
#define H(x) P(#x << ": " << x)
#define FR(i, a, b) for(int i = (a); i < (b); ++i)
#define F(i, n) FR(i, 0, n)
#define DR(i, a, b) for(int i = (b); i --> (a);)
#define D(i, n) DR(i, 0, n)
#define S(s) (int)(s).size()
#define ALL(x) (x).begin(), (x).end()
#define MI(x, a) (x) = min(x, a)
#define MA(x, a) (x) = max(x, a)
#define V vector
#define pb push_back
#define mp make_pair
using namespace std;
const bool debug = 0;
const int inf = 1e18;
int N,M;

vector<string> A;
vector<vector<vector<bool> > > vis;
bool isRGW(int x, int y, bool vh){ /*0 is horizontal 1 is vertical*/
	if(x-vh>=0 && x+vh<N && y-1+vh>=0 && y+1-vh<M){
		if(vh==0) return A[x][y] == 'G' && A[x][y-1] == 'R' && A[x][y+1] == 'W';
		else return A[x][y] == 'G' && A[x-1][y] == 'R' && A[x+1][y] == 'W';
	}
	return false;
}

bool isleaf(int x, int y, bool vh){
	return isRGW(x,y,vh) && isRGW(x,y,!vh) + isRGW(x-1,y+1,!vh) + isRGW(x+1,y-1,!vh) <= 1;
}
int v; int h;
void dfs(int x, int y, bool vh){
	if(!isRGW(x,y,vh) || vis[x][y][vh]){
		return;
	}
	vis[x][y][vh] = true;
	if(vh){
		v++;
	}
	else{
		h++;
	}
	dfs(x,y,!vh);
	dfs(x+1,y-1,!vh);
	dfs(x-1,y+1,!vh);
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M;
	
	A.resize(N);
	F(i,N){
		cin>>A[i];
	}
	int ans = 0;
	F(i,N) F(j,M) F(b,2){
		if(isleaf(i,j,b)){
			H(i);
			H(j);
			H(b);
			A[i][j] = '0';
			A[i+b][j+1-b] = '0';
			A[i-b][j-1+b] = '0';
			P("a");
			ans++;
		}	
	}

	F(j,M) F(i,N) F(b,2){
		if(isleaf(i,j,b)){
			H(i);
			H(j);
			H(b);
			A[i][j] = '0';
			A[i+1-b][j+b] = '0';
			A[i-1+b][j-b] = '0';
			ans++;
		}	
	}
	vis.resize(N,vector<vector<bool> > (M,vector<bool> (2,0)));
	F(i,N) F(j,M) F(b,2){
		v = 0; h = 0;
		if(N<1000||M<1000) dfs(i,j,b);
		ans+=max(v,h);
	
	cout<<ans<<endl;
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:93:1: error: expected '}' at end of input
 }
 ^