Submission #81899

#TimeUsernameProblemLanguageResultExecution timeMemory
81899zoooma13Dango Maker (JOI18_dango_maker)C++14
13 / 100
3 ms1020 KiB
#include <bits/stdc++.h>
using namespace std;

#define MAX_N 3005

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

set <int> Adj[MAX_N];

int idx = 0;
int id1[MAX_N][MAX_N];
int id2[MAX_N][MAX_N];

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

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

    for(const 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')
            id1[i][j] = id1[i][j+1] = id1[i][j+2] = ++idx;

    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')
            id2[i][j] = id2[i+1][j] = id2[i+2][j] = ++idx;

    for(int i=0; i<N; i++)
    for(int j=0; j<M; j++)
        if(id1[i][j] != id2[i][j] && min(id1[i][j] ,id2[i][j]) != 0)
        {
            Adj[id1[i][j]].insert(id2[i][j]);
            Adj[id2[i][j]].insert(id1[i][j]);
        }

    int Ans = 0;
    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 (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:30: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:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",G[i]);
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...