답안 #1109038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109038 2024-11-05T21:28:00 Z codexistent Dango Maker (JOI18_dango_maker) C++14
0 / 100
2 ms 760 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXNM 3005
#define FOR(i, a, b) for(ll i = a; i <= b; i++)

ll n, m, r = 0;
char g[MAXNM][MAXNM];
bool ok[MAXNM][MAXNM][2], dp[MAXNM * 2][3];
vector<array<int, 2>> e[MAXNM * 2];

int main(){
    cin >> n, m;
    FOR(i, 1, n){
        string s; cin >> s;
        FOR(j, 1, m) g[i][j] = s[j - 1];
    } 

    FOR(i, 1, n){
        FOR(j, 1, m){
            ok[i][j][0] = (g[i][j - 1] == 'R' && g[i][j] == 'G' && g[i][j + 1] == 'W');
            ok[i][j][1] = (g[i - 1][j] == 'R' && g[i][j] == 'G' && g[i + 1][j] == 'W');

            e[i + j].push_back({i, j});
        }
    }

    FOR(i, 1, n + m){
        int f = (int)e[i].size() - 1;
        if(e[i].empty()) continue;

        dp[0][0] = ok[e[i][0][0]][e[i][0][1]][0];
        dp[0][1] = ok[e[i][0][0]][e[i][0][1]][1];
        dp[0][2] = 0;
        FOR(j, 1, e[i].size() - 1){
            int x = e[i][j][0], y = e[i][j][1];
            dp[j][2] = max({dp[j - 1][0], dp[j - 1][1], dp[j - 1][2]});
            dp[j][0] = max(dp[j - 1][0], dp[j - 1][2]) + ok[x][y][0];
            dp[j][1] = max(dp[j - 1][1], dp[j - 1][2]) + ok[x][y][1];
        }

        r += max({dp[f][0], dp[f][1], dp[f][2]});
    }

    cout << r << endl;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:13:16: warning: right operand of comma operator has no effect [-Wunused-value]
   13 |     cin >> n, m;
      |                ^
dango_maker.cpp:24:33: warning: narrowing conversion of 'i' from 'long long int' to 'int' [-Wnarrowing]
   24 |             e[i + j].push_back({i, j});
      |                                 ^
dango_maker.cpp:24:36: warning: narrowing conversion of 'j' from 'long long int' to 'int' [-Wnarrowing]
   24 |             e[i + j].push_back({i, j});
      |                                    ^
dango_maker.cpp:5:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define FOR(i, a, b) for(ll i = a; i <= b; i++)
......
   35 |         FOR(j, 1, e[i].size() - 1){
      |             ~~~~~~~~~~~~~~~~~~~~~     
dango_maker.cpp:35:9: note: in expansion of macro 'FOR'
   35 |         FOR(j, 1, e[i].size() - 1){
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 760 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Incorrect 1 ms 592 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 760 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Incorrect 1 ms 592 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 760 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Incorrect 1 ms 592 KB Output isn't correct
7 Halted 0 ms 0 KB -