Submission #891582

#TimeUsernameProblemLanguageResultExecution timeMemory
891582frostray8653Dango Maker (JOI18_dango_maker)C++17
100 / 100
195 ms238676 KiB
#include <bits/stdc++.h> #define int long long #define IO ios::sync_with_stdio(0), cin.tie(0) #define FOR(i, a, b) for (int i = a; i <= b; i++) using namespace std; using pii = pair<int, int>; void dbg() {;} template<class T, class ...U> void dbg(T a, U ...b) { cout << a << " "; dbg(b...); } void ent() { cout << "\n"; } const int N = 3005; char a[N][N]; int n, m; bool can_x[N][N], can_y[N][N]; int dp[N][N], dpx[N][N], dpy[N][N]; signed main() { IO; cin >> n >> m; FOR(i, 1, n) FOR(j, 1, m) cin >> a[i][j]; auto inside = [&](int x, int y) { return (1 <= x && x <= n && 1 <= y && y <= m); }; FOR(i, 1, n) { FOR(j, 1, m) { if (inside(i - 1, j) && inside(i + 1, j) && a[i - 1][j] == 'R' && a[i][j] == 'G' && a[i + 1][j] == 'W') can_x[i][j] = true; if (inside(i, j - 1) && inside(i, j + 1) && a[i][j - 1] == 'R' && a[i][j] == 'G' && a[i][j + 1] == 'W') can_y[i][j] = true; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (can_x[i][j]) { dpx[i][j] = max(dpx[i - 1][j + 1], dp[i - 1][j + 1]) + 1; } if (can_y[i][j]) { dpy[i][j] = max(dpy[i - 1][j + 1], dp[i - 1][j + 1]) + 1; } dp[i][j] = max({dp[i - 1][j + 1], dpx[i - 1][j + 1], dpy[i - 1][j + 1]}); } } int ans = 0; for (int i = 1; i <= n; i++) ans += max({dp[i][1], dpx[i][1], dpy[i][1]}); for (int j = 2; j <= m; j++) ans += max({dp[n][j], dpx[n][j], dpy[n][j]}); cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...