Submission #330242

# Submission time Handle Problem Language Result Execution time Memory
330242 2020-11-24T08:40:27 Z Seanliu Dango Maker (JOI18_dango_maker) C++14
13 / 100
1 ms 512 KB
#include <iostream>
#include <string.h>
using namespace std;

const int maxN = 3e3 + 326;
string mp[maxN];

int N, M, dp[maxN][maxN][4], ans[maxN * 2], r;
bool canV[maxN][maxN], canH[maxN][maxN];
int main(){
	cin >> N >> M;
	for(int i = 0; i < N; i++){
		cin >> mp[i];
	}
	//for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cout << mp[i][j] << " \n"[j == M - 1];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			canV[i][j] = i < N - 2 && (mp[i][j] == 'R' && mp[i + 1][j] == 'G' && mp[i + 2][j] == 'W');
			canH[i][j] = j < M - 2 && (mp[i][j] == 'R' && mp[i][j + 1] == 'G' && mp[i][j + 2] == 'W');
			if(i - 1 < 0 || j + 1 >= M){
				dp[i][j][2] = (canV[i][j]);	
				dp[i][j][0] = (canH[i][j]);	
				ans[i + j] = max(ans[i + j], dp[i][j][2]);
				ans[i + j] = max(ans[i + j], dp[i][j][0]);
				//cout << "dp[" << i << "][" << j << "][" << 0 << "] = " << dp[i][j][0] << endl;
				//cout << "dp[" << i << "][" << j << "][" << 2 << "] = " << dp[i][j][2] << endl;
			} else {
				dp[i][j][0] = max(max(dp[i - 1][j + 1][1], dp[i - 1][j + 1][0]), canH[i][j] * (dp[i - 1][j + 1][0] + 1));
				dp[i][j][1] = max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][3]);
				if(canV[i][j]){
					dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1]) + 1;
					dp[i][j][3] = max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][3]) + 1;
				}
				for(int k = 0; k < 3; k++){
					ans[i + j] = max(ans[i + j], dp[i][j][k]);
					//cout << "dp[" << i << "][" << j << "][" << k << "] = " << dp[i][j][k] << endl;
				}
			}
		}
	}
	/*
	for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cout << canV[i][j] << " \n"[j == M - 1];
	cout << endl;
	for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cout << canH[i][j] << " \n"[j == M - 1];
	cout << endl;
	*/
	for(int i = 0; i < N + M; i++) r += ans[i];
	cout << r << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 484 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 484 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Incorrect 1 ms 492 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 484 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Incorrect 1 ms 492 KB Output isn't correct
21 Halted 0 ms 0 KB -