제출 #332845

#제출 시각아이디문제언어결과실행 시간메모리
332845parsabahramiDango Maker (JOI18_dango_maker)C++17
100 / 100
192 ms18156 KiB
#include <bits/stdc++.h>
 
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
 
#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 3e3 + 10, MOD = 1e9 + 7;
int n, m, dp[2][N], R = 0;
char S[N][N];

int pain(int i, int j) {
	return (S[i][j] == 'R' && S[i + 1][j] == 'G' && S[i + 2][j] == 'W' && i + 2 <= n);
}

int rast(int i, int j) {
	return (S[i][j] == 'R' && S[i][j + 1] == 'G' && S[i][j + 2] == 'W' && j + 2 <= m);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%s", S[i] + 1);
	}
	for (int _ = 2; _ <= n + m; _++) {
		fill(dp[0], dp[0] + N, 0); int res = 0;
		fill(dp[1], dp[1] + N, 0);
		for (int i = 1, j; i <= n && i <= _ - 1; i++) {
			j = _ - i;
			if (j > m) continue;
			if (i >= 2) dp[0][i] = max(dp[0][i - 1], dp[1][i - 2]);
			dp[1][i] = dp[1][i - 1];
			if (pain(i, j)) dp[1][i] = max({dp[1][i], dp[0][i - 1] + 1, dp[1][i - 1] + 1});
			if (rast(i, j)) dp[0][i] = max(dp[0][i], dp[0][i - 1] + 1);
			res = max({res, dp[0][i], dp[1][i]});
		}
		R += res;
	}
	printf("%d\n", R);
	return 0;
}

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

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |   scanf("%s", S[i] + 1);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...