Submission #1187796

#TimeUsernameProblemLanguageResultExecution timeMemory
1187796jerzykDango Maker (JOI18_dango_maker)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define st first #define nd second typedef long long ll; typedef long double ld; const ll I = 1'000'000'000'000'000'000LL; const int II = 2'000'000'000; const ll M = 1'000'000'007LL; const int N = 3007; string s[N]; int dp[N][N][2]; void Solve() { int n, m; cin >> n >> m; for(int i = 1; i <= n; ++i) { cin >> s[i]; s[i] = '!' + s[i]; } for(int i = 1; i <= n; ++i) for(int j = m; j >= 1; --j) { for(int r = 0; r < 2; ++r) dp[i][j][r] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1]); if(j + 2 <= m && s[i][j] == 'R' && s[i][j + 1] == 'G' && s[i][j + 2] == 'W') dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j + 1][0] + 1); if(i + 2 <= n && s[i][j] == 'R' && s[i + 1][j] == 'G' && s[i + 2][j] == 'W') ++dp[i][j][1]; } int ans = 0; for(int i = 1; i <= n; ++i) ans += max(dp[i][1][0], dp[i][1][1]); for(int j = 2; j <= m; ++j) ans += max(dp[n][j][0], dp[n][j][1]); cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //int t; cin >> t; //while(t--) Solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...