제출 #591937

#제출 시각아이디문제언어결과실행 시간메모리
591937hibikiDango Maker (JOI18_dango_maker)C++11
100 / 100
212 ms123792 KiB
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()

int n,m;
char pic[3005][3005];
int dp[3005][3005][3];

int main()
{
    scanf("%d %d",&n,&m);
    for(int i = 1; i <= n; i++)
        scanf("%s",pic[i] + 1);
    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(pic[i][j - 1] == 'R' && pic[i][j] == 'G' && pic[i][j + 1] == 'W')
            {
                dp[i][j][1] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1]) + 1;
            }
            if(pic[i - 1][j] == 'R' && pic[i][j] == 'G' && pic[i + 1][j] == 'W')
            {
                dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][2]) + 1;
            }
        }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        ans += max({dp[i][1][0], dp[i][1][1], dp[i][1][2]});
    }
    for(int j = 2; j <= m; j++)
    {
        ans += max({dp[n][j][0], dp[n][j][1], dp[n][j][2]});
    }
    printf("%d\n",ans);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
dango_maker.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%s",pic[i] + 1);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...