Submission #117726

#TimeUsernameProblemLanguageResultExecution timeMemory
117726abacabaDango Maker (JOI18_dango_maker)C++14
0 / 100
2 ms384 KiB
#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] + dp[i-1][j] - dp[i-1][j-1]; int val = 0; for(int k = 0; k < 3; ++k) { val += check(a[i-k][j-2], a[i-k][j-1], a[i-k][j]); 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] + val2); } } } // for(int i = 3; i <= n; ++i, cout << endl) // for(int j = 3; j <= m; ++j) // cout << dp[i][j] << ' '; cout << dp[n][m]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...