제출 #153802

#제출 시각아이디문제언어결과실행 시간메모리
153802mhy908Dango Maker (JOI18_dango_maker)C++14
100 / 100
213 ms9464 KiB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, m;
char str[3010][3010];
int dp[6010], arr[6010], ans;
int main()
{
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++)scanf("%s", str[i]+1);
    for(int i=2; i<=n+m; i++){
        memset(dp, 0, sizeof(dp));
        memset(arr, 0, sizeof(arr));
        for(int j=1; j<i; j++){
            dp[j]=dp[j-1];
            int x=i-j, y=j;
            if(x>n||y>m)continue;
            if(str[x][y]=='G'&&str[x-1][y]=='R'&&str[x+1][y]=='W')arr[j]+=1;
            if(str[x][y]=='G'&&str[x][y-1]=='R'&&str[x][y+1]=='W')arr[j]+=2;
            if(!arr[j-1]&&arr[j])dp[j]++;
            else if(arr[j]==3)dp[j]++;
            else if(arr[j]==1&&(arr[j-1]&1))dp[j]++;
            else if(arr[j]==2&&(arr[j-1]&2))dp[j]++;
            if(arr[j]==3&&arr[j-1]==1)arr[j]=1;
            if(arr[j]==3&&arr[j-1]==2)arr[j]=2;
            if(dp[j]==dp[j-1])arr[j]=0;
        }
        ans+=dp[i-1];
    }
    printf("%d", ans);
}

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

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:17: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:18:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%s", str[i]+1);
                            ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...