답안 #680138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680138 2023-01-10T02:13:10 Z Duy_e Dango Maker (JOI18_dango_maker) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, ll>
#define st first
#define nd second
#define file "test"
#define rep(i, begin, end) for (ll i = (begin); i <= (end); i ++)
#define rrep(i, begin, end) for (ll i = (begin); i >= (end); i --)
using namespace std;
const long long INF = 1e18;
const long long N = 2e5 + 5;

ll dp[N][3], n, m, ans;
char a[3005][3005];

bool check(char a, char b, char c) {
    return a == 'R' && b == 'G' && c == 'W';
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        .//freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    #endif
    
    cin >> n >> m;
    rep(i, 1, n) rep(j, 1, m) cin >> a[i][j];

    rep(s, 2, n + m) {
        
        ll res = 0;
        rep(j, 1, m) dp[j][1] = dp[j][2] = 0;

        rep(j, 1, m) {
            int i = s - j;
            // dp[j][0] = dp[j][1] = dp[j][2] = 0;
            if (i < 1 || i > n) continue;

            // 0: nothing
            // 1: vertical
            // 2: horizontal
            // if (s == 4) cout << i << ' ' << j << '\n';


            if (i > 2 && check(a[i - 2][j], a[i - 1][j], a[i][j]))
                dp[j][1] = max(max(dp[j - 1][2], dp[j - 1][1]), j > 3 ? dp[j - 3][2] : 0) + 1;
            
            if (j > 2 && check(a[i][j - 2], a[i][j - 1], a[i][j]))
                dp[j][2] = max(dp[j - 1][2], j > 3 ? dp[j - 3][1] : 0) + 1;
        
            res = max(res, max(dp[j][1], dp[j][2]));
        }

        // cout << s << ": " << res << '\n';

        ans += res;
    }

    cout << ans << '\n';

    return 0;
}    
/**  /\_/\
*   (= ._.)
*   / >🍵 \>🍮
**/

Compilation message

dango_maker.cpp:64:9: warning: "/*" within comment [-Wcomment]
   64 | /**  /\_/\
      |          
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:24:9: error: expected primary-expression before '.' token
   24 |         .//freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
      |         ^