제출 #163429

#제출 시각아이디문제언어결과실행 시간메모리
163429iefnah06Dango Maker (JOI18_dango_maker)C++11
100 / 100
319 ms18168 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXL = 3010;
int X, Y;
char G[MAXL][MAXL];

int main() {
	scanf("%d %d", &X, &Y);
	for (int x = 1; x <= X; x++) {
		scanf("%s", G[x] + 1);
	}

	int ans = 0;
	for (int xpy = 1; xpy <= X + Y; xpy++) {
		array<int, 3> dp = {};
		for (int x = 1; x <= X; x++) {
			int y = xpy - x;
			if (y < 1 || y > Y) continue;

			array<int, 3> ndp = {};

			// horizontal
			if (G[x][y - 1] == 'R' && G[x][y] == 'G' && G[x][y + 1] == 'W') {
				ndp[0] = 1 + max(dp[0], dp[2]);
			}

			// vertical
			if (G[x - 1][y] == 'R' && G[x][y] == 'G' && G[x + 1][y] == 'W') {
				ndp[1] = 1 + max(dp[1], dp[2]);
			}

			// do nothing
			ndp[2] = *max_element(dp.begin(), dp.end());

			swap(dp, ndp);
		}
		ans += *max_element(dp.begin(), dp.end());
	}
	printf("%d\n", ans);

	return 0;
}

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

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &X, &Y);
  ~~~~~^~~~~~~~~~~~~~~~~
dango_maker.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", G[x] + 1);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...