# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1147414 | mingga | Dango Maker (JOI18_dango_maker) | C++20 | 282 ms | 71084 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int mod = 1e9 + 7;
const int inf = 2e18;
const int N = 3005;
int f[N][3], n, m;
int a[N][N];
bool check_hor(int x, int y) {
if(y <= 2) return false;
for(int i = 2; i >= 0; i--) {
if(a[x][y - i] != 2 - i) return false;
}
return true;
}
bool check_ver(int x, int y) {
if(x <= 2) return false;
for(int i = 2; i >= 0; i--) {
if(a[x - i][y] != 2 - i) return false;
}
return true;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n >> m;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
char x; cin >> x;
if(x == 'G') a[i][j] = 1;
else if(x == 'W') a[i][j] = 2;
}
}
int ans = 0;
for(int x = 2; x <= m + n; x++) {
int st = max(1ll, x - m), en = min(n, x - 1);
memset(f, 0, sizeof f);
for(int i = st; i <= en; i++) {
int j = x - i;
for(int t = 0; t < 3; t++) f[i][0] = max(f[i][0], f[i - 1][t]);
if(check_hor(i, j)) {
for(int t = 0; t <= 3; t++) f[i][1] = max(f[i][1], f[i - 1][t] + 1);
}
if(check_ver(i, j)) {
f[i][2] = max({f[i - 1][2], f[i - 2][2], f[i - 2][0]}) + 1;
}
}
ans += max({f[en][0], f[en][1], f[en][2]});
}
cout << ans << ln;
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |