제출 #66766

#제출 시각아이디문제언어결과실행 시간메모리
66766yusufakeDango Maker (JOI18_dango_maker)C++98
13 / 100
3 ms752 KiB
#include<bits/stdc++.h> 
using namespace std; 

#define mp make_pair 
#define pb push_back 
#define st first 
#define nd second 

typedef long long ll; 
typedef pair < int , int > pp; 
const int mod = 1e9 + 7; 
const int N   = 3e3 + 3; 

int H[N][N][2],m,n,i,j,ans,nn,z;
char A[N][N];

void f(int x, int y, int h){
    if(H[x][y][h]) return;
    H[x][y][h] = 1;
    nn++;
    z += h;
    if(h){
        if(y <= n-2 && A[x][y+1] == 'G' && A[x][y+2] == 'W') f(x,y,!h);
        if(y >= 2 && y <= n-1 && A[x+1][y-1] == 'R' && A[x+1][y+1] == 'W') f(x+1,y-1,!h);
        if(y >= 3 && A[x+2][y-2] == 'R' && A[x+2][y-1] == 'G') f(x+2,y-2,!h);
    }
    else{
        if(x <= m-2 && A[x+1][y] == 'G' && A[x+2][y] == 'W') f(x,y,!h);
        if(x <= m-1 && x >= 2 && A[x-1][y+1] == 'R' && A[x+1][y+1] == 'W') f(x-1,y+1,!h);
        if(x >= 3 && A[x-2][y+2] == 'R' && A[x-1][y+2] == 'G') f(x-2,y+2,!h);
    }
    
}

int main(){
    scanf("%d%d",&m,&n);
    for(i=1;i<=m;i++)
        for(j=1;j<=n;j++)
            scanf(" %c", &A[i][j]);
            
    for(i=1;i<=m;i++)
        for(j=1;j<=n-2;j++){
            if(A[i][j] == 'R' && A[i][j+1] == 'G' && A[i][j+2] == 'W'){
                nn = z = 0;
                f(i,j,0);
                ans += max(z , nn-z);
            }
        }
    for(i=1;i<=m-2;i++)
        for(j=1;j<=n;j++){
            if(A[i][j] == 'R' && A[i+1][j] == 'G' && A[i+2][j] == 'W'){
                nn = z = 0;
                f(i,j,1);
                ans += max(z , nn-z);
            }
        }
    
    printf("%d",ans);
    return 0;
}

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

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