# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
650757 | 2022-10-15T08:54:27 Z | Shin | Dango Maker (JOI18_dango_maker) | C++14 | 1 ms | 340 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair using namespace std; template <class X, class Y> bool minimize(X &a, Y b) { if (a > b) return a = b, true; return false; } template <class X, class Y> bool maximize(X &a, Y b) { if (a < b) return a = b, true; return false; } const int N = 5e3 + 7; char a[N][N]; int dp[N][N][2]; signed main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= m; j ++) { cin >> a[i][j]; } } int res = 0; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= m; j ++) { dp[i][j][0] = max({dp[i - 1][j + 1][0], dp[i - 1][j + 1][1], dp[i - 1][j + 1][2]}); if (a[i][j] == 'G' && a[i][j - 1] == 'R' && a[i][j + 1] == 'W') { maximize(dp[i][j][1], max(dp[i - 1][j + 1][1], dp[i - 1][j + 1][0]) + 1); } if (a[i][j] == 'G' && a[i - 1][j] == 'R' && a[i + 1][j] == 'W') { maximize(dp[i][j][2], max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][0]) + 1); } if (j == 1 || i == n) { res += max({dp[i][j][0], dp[i][j][1], dp[i][j][2]}); } } } cout << res; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Incorrect | 1 ms | 340 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Incorrect | 1 ms | 340 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Incorrect | 1 ms | 340 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |