Submission #153408

#TimeUsernameProblemLanguageResultExecution timeMemory
153408mhy908Dango Maker (JOI18_dango_maker)C++14
13 / 100
80 ms70928 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define llinf 987654321987654321 using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; int n, m, x; char str[3010][3010]; int col[3010][3010][3], re[3010][3010], ans; vector<int> link[3000010]; int ishere[3000010]; int onenum, twonum; void dfs(int here, int c) { if(ishere[here])return; ishere[here]=c; if(c==1)onenum++; else twonum++; for(int i=0; i<link[here].size(); i++){ dfs(link[here][i], c==1?2:1); } } int main() { scanf("%d%d", &n, &m); for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ scanf(" %c", &str[i][j]); } } for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ if(str[i][j]=='R'&&str[i][j+1]=='G'&&str[i][j+2]=='W'){ ++x; col[i][j][++re[i][j]]=x; col[i][j+1][++re[i][j+1]]=x; col[i][j+2][++re[i][j+2]]=x; } if(str[i][j]=='R'&&str[i+1][j]=='G'&&str[i+2][j]=='W'){ ++x; col[i][j][++re[i][j]]=x; col[i+1][j][++re[i+1][j]]=x; col[i+2][j][++re[i+2][j]]=x; } } } for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ if(re[i][j]==2){ link[col[i][j][1]].pb(col[i][j][2]); link[col[i][j][2]].pb(col[i][j][1]); } } } for(int i=1; i<=x; i++){ if(ishere[i])continue; onenum=twonum=0; dfs(i, 1); ans+=max(onenum, twonum); } printf("%d", ans); }

Compilation message (stderr)

dango_maker.cpp: In function 'void dfs(int, int)':
dango_maker.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<link[here].size(); i++){
                  ~^~~~~~~~~~~~~~~~~~
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:28: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:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c", &str[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...