제출 #103051

#제출 시각아이디문제언어결과실행 시간메모리
103051tincamateiDango Maker (JOI18_dango_maker)C++14
100 / 100
237 ms88704 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 3000;

int dp[2][1+MAX_N+1][1+MAX_N+1];
char matr[1+MAX_N+1][1+MAX_N+1];

char getch(FILE *fin) {
	char ch = fgetc(fin);
	while(!isalpha(ch))
		ch = fgetc(fin);
	return ch;
}

int main() {
#ifdef HOME
	FILE *fin = fopen("input.in", "r");
	FILE *fout = fopen("output.out", "w");
#else
	FILE *fin = stdin;
	FILE *fout = stdout;
#endif

	int n, m;
	fscanf(fin, "%d%d", &n, &m);
	
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			matr[i][j] = getch(fin);
	
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j) {
			dp[0][i][j] = max(dp[0][i - 1][j + 1], dp[1][i - 1][j + 1]);
			dp[1][i][j] = dp[0][i][j];
			if(matr[i][j] == 'G' && matr[i][j - 1] == 'R' && matr[i][j + 1] == 'W')
				dp[0][i][j] = max(dp[0][i][j], dp[0][i - 1][j + 1] + 1);
			if(matr[i][j] == 'G' && matr[i - 1][j] == 'R' && matr[i + 1][j] == 'W')
				dp[1][i][j] = max(dp[1][i][j], dp[1][i - 1][j + 1] + 1);
		}
	
	int rez = 0;
	for(int i = 1; i <= n; ++i)
		rez = rez + max(dp[0][i][1], dp[1][i][1]);
	for(int i = 2; i <= m; ++i)
		rez = rez + max(dp[0][n][i], dp[1][n][i]);

	fprintf(fout, "%d", rez);

	fclose(fin);
	fclose(fout);
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:27:8: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fin, "%d%d", &n, &m);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...