Submission #264898

# Submission time Handle Problem Language Result Execution time Memory
264898 2020-08-14T10:57:19 Z sahil_k Dango Maker (JOI18_dango_maker) C++14
0 / 100
1 ms 384 KB
#include <iostream>
using namespace std;
#define MAXN 3005
int n, m;
char grid[MAXN][MAXN];
bool l[MAXN][MAXN], u[MAXN][MAXN];
int dp[MAXN][3];
int o = 0;
int main () {
	cin >> n >> m;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> grid[i][j];
		}
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			if (grid[i][j] != 'G') continue;
			if (i > 0 && i < n-1 && grid[i-1][j] == 'R' && grid[i+1][j] == 'W') u[i][j] = true;
			if (j > 0 && j < m-1 && grid[i][j-1] == 'R' && grid[i][j+1] == 'W') l[i][j] = true;
		}
	}
	for (int i=0; i<m; i++) {
		int x = 0, y = i;
		int dist = min(i, n-1);
		dp[0][0] = 0;
		dp[0][1] = l[x][y];
		dp[0][2] = u[x][y];
		x++; y--;
		for (int j=1; j<=dist; j++) {
			dp[j][0] = max(dp[j-1][0], max(dp[j-1][1], dp[j-1][2]));
			dp[j][1] = max(dp[j-1][0], dp[j-1][2])+l[x][y];
			dp[j][2] = max(dp[j-1][0], dp[j-1][1])+u[x][y];
			x++; y--;
		}
		o += max(dp[dist][0], max(dp[dist][1], dp[dist][2]));
	}
	for (int i=n-2; i>=0; i--) {
		int x=n-i-1, y = m-1;
		int dist = min(i, m-1);
		dp[0][0] = 0;
		dp[0][1] = l[x][y];
		dp[0][2] = u[x][y];
		x++; y--;
		for (int j=1; j<=dist; j++) {
			dp[j][0] = max(dp[j-1][0], max(dp[j-1][1], dp[j-1][2]));
			dp[j][1] = max(dp[j-1][0], dp[j-1][2])+l[x][y];
			dp[j][2] = max(dp[j-1][0], dp[j-1][1])+u[x][y];
			x++; y--;
		}
		o += max(dp[dist][0], max(dp[dist][1], dp[dist][2]));
	}
	cout << o << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -