답안 #81891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
81891 2018-10-27T15:20:05 Z zoooma13 Dango Maker (JOI18_dango_maker) C++14
0 / 100
2 ms 696 KB
#include <bits/stdc++.h>
using namespace std;

#define MAX_N 3005

int N ,M;
char G[MAX_N][MAX_N];

vector <int> Adj[MAX_N];

int idx = 0;
int id[MAX_N][MAX_N];

int vis[MAX_N*MAX_N];
int Ev ,Od;

void DFS(int Q ,bool S)
{
    Ev += !S ,Od += S;
    vis[Q] = 1;

    for(int&i : Adj[Q])
        if(!vis[i])
            DFS(i ,!S);
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i=0; i<N; i++)
        scanf("%s",G[i]);

    for(int i=0; i<N; i++)
    for(int j=0; j<M-2; j++)
        if(G[i][j] == 'R' && G[i][j+1] == 'G' && G[i][j+2] == 'W')
            id[i][j] = id[i][j+1] = id[i][j+2] = ++idx;

    int Ans = 0;

    for(int i=0; i<N-2; i++)
    for(int j=0; j<M; j++)
        if(G[i][j] == 'R' && G[i+1][j] == 'G' && G[i+2][j] == 'W')
        {
            if(id[i][j]){
                if(id[i+1][j])
                    Adj[id[i][j]].push_back(id[i+1][j]),
                    Adj[id[i+1][j]].push_back(id[i][j]);
                if(id[i+2][j])
                    Adj[id[i][j]].push_back(id[i+2][j]),
                    Adj[id[i+2][j]].push_back(id[i][j]);
            }
            else
                Ans++;
        }

    for(int i=1; i<=idx; i++)
    {
        Ev = 0 ,Od = 0;
        if(!vis[i])
            DFS(i ,0);
        Ans += max(Ev ,Od);
    }

    printf("%d\n",Ans);
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:29: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:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",G[i]);
         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 680 KB Output is correct
6 Incorrect 2 ms 696 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 680 KB Output is correct
6 Incorrect 2 ms 696 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 680 KB Output is correct
6 Incorrect 2 ms 696 KB Output isn't correct
7 Halted 0 ms 0 KB -