Submission #889293

#TimeUsernameProblemLanguageResultExecution timeMemory
889293alexander707070Dango Maker (JOI18_dango_maker)C++14
0 / 100
34 ms146092 KiB
#include<bits/stdc++.h> #define MAXN 6000007 using namespace std; int n,m; char t[3007][3007]; vector<int> v[MAXN]; int s[MAXN],cnt1,cnt2,ans; int num[3007][3007],num2[3007][3007],total; 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=0;i<=n+1;i++){ for(int f=0;f<=m+1;f++){ t[i][f]='#'; } } 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'){ total++; num[i][f]=total; } if(t[i][f]=='R' and t[i+1][f]=='G' and t[i+2][f]=='W'){ total++; num2[i][f]=total; } 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[num[i][f]].push_back(num2[i][f]); //v[num2[i][f]].push_back(num[i][f]); } } } for(int i=1;i<=n;i++){ for(int f=1;f<=m;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[num[i][f-1]].push_back(num2[i-1][f]); v[num2[i-1][f]].push_back(num[i][f-1]); } } } for(int i=2;i<=n;i++){ for(int f=2;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[num[i][f-2]].push_back(num2[i-2][f]); v[num2[i-2][f]].push_back(num[i][f-2]); } } } for(int i=1;i<=total;i++){ if(s[i]==0){ cnt1=cnt2=0; dfs(i,0,1); ans+=max(cnt1,cnt2); } } cout<<ans<<"\n"; return 0; }

Compilation message (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...