답안 #66766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66766 2018-08-12T09:29:08 Z yusufake Dango Maker (JOI18_dango_maker) C++
13 / 100
3 ms 752 KB
#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;
}

Compilation message

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]);
             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 736 KB Output is correct
7 Correct 2 ms 736 KB Output is correct
8 Correct 3 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 3 ms 736 KB Output is correct
12 Correct 3 ms 736 KB Output is correct
13 Correct 3 ms 736 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 3 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 736 KB Output is correct
7 Correct 2 ms 736 KB Output is correct
8 Correct 3 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 3 ms 736 KB Output is correct
12 Correct 3 ms 736 KB Output is correct
13 Correct 3 ms 736 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 3 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 736 KB Output is correct
18 Correct 3 ms 736 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 2 ms 736 KB Output is correct
21 Correct 2 ms 748 KB Output is correct
22 Correct 2 ms 748 KB Output is correct
23 Correct 2 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 2 ms 748 KB Output is correct
26 Correct 2 ms 748 KB Output is correct
27 Correct 3 ms 752 KB Output is correct
28 Correct 2 ms 752 KB Output is correct
29 Correct 2 ms 752 KB Output is correct
30 Correct 2 ms 752 KB Output is correct
31 Correct 3 ms 752 KB Output is correct
32 Correct 2 ms 752 KB Output is correct
33 Correct 2 ms 752 KB Output is correct
34 Incorrect 2 ms 752 KB Output isn't correct
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 3 ms 736 KB Output is correct
7 Correct 2 ms 736 KB Output is correct
8 Correct 3 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 3 ms 736 KB Output is correct
12 Correct 3 ms 736 KB Output is correct
13 Correct 3 ms 736 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 3 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 736 KB Output is correct
18 Correct 3 ms 736 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 2 ms 736 KB Output is correct
21 Correct 2 ms 748 KB Output is correct
22 Correct 2 ms 748 KB Output is correct
23 Correct 2 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 2 ms 748 KB Output is correct
26 Correct 2 ms 748 KB Output is correct
27 Correct 3 ms 752 KB Output is correct
28 Correct 2 ms 752 KB Output is correct
29 Correct 2 ms 752 KB Output is correct
30 Correct 2 ms 752 KB Output is correct
31 Correct 3 ms 752 KB Output is correct
32 Correct 2 ms 752 KB Output is correct
33 Correct 2 ms 752 KB Output is correct
34 Incorrect 2 ms 752 KB Output isn't correct
35 Halted 0 ms 0 KB -