제출 #889249

#제출 시각아이디문제언어결과실행 시간메모리
889249alexander707070Dango Maker (JOI18_dango_maker)C++14
0 / 100
51 ms262144 KiB
#include<bits/stdc++.h>
#define MAXN 20000007
using namespace std;

int n,m;
char t[3007][3007];

vector<int> v[MAXN];
int s[MAXN],cnt1,cnt2,ans;
bool ok[MAXN];

void dfs(int x,int p,int side){
    s[x]=side;
    if(side==1)cnt1++;
    else cnt2++;

    for(int i=0;i<v[x].size();i++){
        if(v[x][i]==p)continue;
        if(s[v[x][i]]==0)dfs(v[x][i],x,3-side);
    }
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            cin>>t[i][f];
        }
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            if(t[i][f]=='R' and t[i][f+1]=='G' and t[i][f+2]=='W')ok[i*m+f]=true;
            if(t[i][f]=='R' and t[i+1][f]=='G' and t[i+2][f]=='W')ok[i*m+f+n*m]=true;

            if(t[i][f]=='R' and t[i][f+1]=='G' and t[i][f+2]=='W' and t[i+1][f]=='G' and t[i+2][f]=='W'){
                v[i*m+f].push_back(i*m+f+n*m);
                v[i*m+f+n*m].push_back(i*m+f);
            }
        }
    }

    for(int i=2;i<=n-1;i++){
        for(int f=2;f<=m-1;f++){
            if(t[i][f]=='G' and t[i][f-1]=='R' and t[i][f+1]=='W' and t[i-1][f]=='R' and t[i+1][f]=='W'){
                v[i*m+f-1].push_back((i-1)*m+f+n*m);
                v[(i-1)*m+f+n*m].push_back(i*m+f-1);
            }
        }
    }

    for(int i=3;i<=n;i++){
        for(int f=3;f<=m;f++){
            if(t[i][f]=='W' and t[i][f-2]=='R' and t[i][f-1]=='G' and t[i-2][f]=='R' and t[i-1][f]=='G'){
                v[i*m+f-2].push_back((i-2)*m+f+n*m);
                v[(i-2)*m+f+n*m].push_back(i*m+f-2);
            }
        }
    }

    for(int i=1;i<=3*n*m;i++){
        if(s[i]==0 and ok[i]){
            cnt1=cnt2=0;
            dfs(i,0,1);
            ans+=max(cnt1,cnt2);
        }
    }

    cout<<ans<<"\n";

    return 0;
}

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

dango_maker.cpp: In function 'void dfs(int, int, int)':
dango_maker.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<v[x].size();i++){
      |                 ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...