제출 #123220

#제출 시각아이디문제언어결과실행 시간메모리
123220arnold518Dango Maker (JOI18_dango_maker)C++14
100 / 100
197 ms18076 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 3000;

int N, M;
char A[MAXN+10][MAXN+10];
int dp[MAXN+10][3], ans;

int main()
{
    int i, j;

    scanf("%d%d", &N, &M);
    for(i=1; i<=N; i++) scanf("%s", A[i]+1);

    for(i=2; i<=N+M; i++)
    {
        int s=max(1, i-N), e=min(M, i-1);
        memset(dp, 0, sizeof(dp));
        for(j=s; j<=e; j++)
        {
            int x=j, y=i-j;
            dp[x][0]=max(dp[x-1][0], max(dp[x-1][1], dp[x-1][2]));
            if(A[y-1][x]=='R' && A[y][x]=='G' && A[y+1][x]=='W') dp[x][1]=max(dp[x-1][0], dp[x-1][1])+1;
            if(A[y][x-1]=='R' && A[y][x]=='G' && A[y][x+1]=='W') dp[x][2]=max(dp[x-1][0], dp[x-1][2])+1;
        }
        ans+=max(dp[e][0], max(dp[e][1], dp[e][2]));
    }
    printf("%d", ans);
}

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

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:19:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%s", A[i]+1);
                         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...