Submission #117766

# Submission time Handle Problem Language Result Execution time Memory
117766 2019-06-17T07:38:51 Z abacaba Dango Maker (JOI18_dango_maker) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define uset unordered_set
#define endl '\n'
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

const int N = 3e3 + 15;
int n, m, k, a[N][N];
int row[N][N], dp[N][N];

inline int check(int a, int b, int c) {
	return a == 1 && b == 2 && c == 3;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	n += 2;
	m += 2;
	for(int i = 3; i <= n; ++i) {
		for(int j = 3; j <= m; ++j) {
			char c;
			cin >> c;
			if(c == 'R')
				a[i][j] = 1;
			else if(c == 'G')
				a[i][j] = 2;
			else
				a[i][j] = 3;
		}
	}
	for(int i = 3; i <= n; ++i) {
		for(int j = 3; j <= m; ++j)
			if(check(a[i][j-2], a[i][j-1], a[i][j]))
				row[i][j] = 1;
		for(int j = 3; j <= m; ++j)
			row[i][j] += row[i][j-1];
	}

	for(int i = 3; i <= n; ++i) {
		for(int j = 3; j <= m; ++j) {

			dp[i][j] = dp[i][j-1];

			int val = 0;
			for(int k = 0; k < 3; ++k) {
				val += row[i-k][j] - row[i-k][j-3];
				dp[i][j] = max(dp[i][j], dp[i][j-3] + dp[i-k-1][j] - dp[i-k-1][j-3] + val);
			}

			int val2 = 0;
			for(int k = 0; k < 3; ++k) {
				val2 += check(a[i-2][j-k], a[i-1][j-k], a[i][j-k]);
				dp[i][j] = max(dp[i][j], dp[i][j-k-1] + dp[i-3][j] - dp[i-3][j-k-1] - row[i-3][j] + row[i-3][j-k-1] + val2);
			}
		}
	}

	cout << dp[n][m];
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 2 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 2 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 2 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -