Submission #547413

# Submission time Handle Problem Language Result Execution time Memory
547413 2022-04-10T16:12:12 Z MilosMilutinovic Dango Maker (JOI18_dango_maker) C++14
0 / 100
1 ms 296 KB
#include <stdio.h>

#define N   3000

int max(int a, int b) { return a > b ? a : b; }

char s[N][N], du[N][N], dr[N][N];
int dp[N + N][3];

int main() {
	int n, m, i, j;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			if (j > 0 && j < m - 1 && s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W')
				dr[i][j] = 1;
			if (i > 0 && i < n - 1 && s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W')
				du[i][j] = 1;
		}
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			int i_, dp_[3];

			dp_[1] = dp_[2] = 0;
			dp_[0] = max(max(dp[i + j][0], dp[i + j][1]), dp[i + j][2]);
			if (dr[i][j] == 1)
				for (i_ = 0; i_ < 3; i_++)
					if (i_ != 1)
						dp_[1] = max(dp_[1], dp[i + j][i_] + 1);
			if (du[i][j] == 1)
				for (i_ = 0; i_ < 3; i_++)
					if (i_ != 2)
						dp_[2] = max(dp_[2], dp[i + j][i_] + 1);
			for (i_ = 0; i_ < 3; i_++)
				dp[i + j][i_] = dp_[i_];
		}
	int ans = 0;
	for (i = 0; i < n + m; i++)
		ans += max(max(dp[i][0], dp[i][1]), dp[i][2]);
	printf("%d\n", ans);
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%s", s[i]);
      |   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 292 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 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 292 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 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 292 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 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -