답안 #1113814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113814 2024-11-17T13:46:17 Z Icelast Dango Maker (JOI18_dango_maker) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 1e9+9;
void solve(){
    int n, m;
    cin >> n >> m;
    vector<string> s(n+1);
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        s[i] = ' ' + s[i];
    }
    vector<vector<bool>> ud(n+1, vector<bool>(m+1, 0)), lr(n+1, vector<bool>(m+1, 0));
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(i > 1 && i < n){
                if(s[i-1][j] == 'R' && s[i][j] == 'G' && s[i+1][j] == 'W'){
                    ud[i][j] = 1;
                }
            }
            if(j > 1 && j < m){
                if(s[i][j-1] == 'R' && s[i][j] == 'G' && s[i][j+1] == 'W'){
                    lr[i][j] = 1;
                }
            }
        }
    }
    auto chmax = [&](int &a, int b) -> void{
        a = max(a, b);
    };
    int ans = 0;
    for(int sum = 2; sum <= 2*n; sum++){
        vector<pair<int, int>> items;
        for(int i = 1; i <= n; i++){
            int j = sum-i;
            if(j < 1 || j > m) continue;
            items.push_back({ud[i][j], lr[i][j]});
        }
        vector<int> f(3, -INF), prv(3, -INF);
        f[0] = 0;
        for(auto it : items){
            prv = f;
            fill(f.begin(), f.end(), -INF);
            chmax(f[0], max({prv[0], prv[1], prv[2]}));
            if(it.first) chmax(f[1], max(prv[0], prv[2])+1);
            if(it.second) chmax(f[2], max(prv[0], prv[1])+1);
        }
        int res = 0;
        for(int j = 0; j <= 2; j++) chmax(res, f[j]);
        ans += res;
    }
    cout << ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Incorrect 1 ms 336 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Incorrect 1 ms 336 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Incorrect 1 ms 336 KB Output isn't correct
9 Halted 0 ms 0 KB -