Submission #79761

#TimeUsernameProblemLanguageResultExecution timeMemory
79761antimirageDango Maker (JOI18_dango_maker)C++17
13 / 100
217 ms71376 KiB
#include <bits/stdc++.h> #define pb emplace_back using namespace std; const int N = 3005; int n, m, d[2][N][N], sz, u[3000005], wh, bl, ans; char ar[N][N]; vector <int> g[3000005]; void dfs (int v, int color) { if (color == 0) wh++; else bl++; u[v] = 1; for (auto to : g[v]) { if (!u[to]) dfs(to, color ^ 1); } } main() { cin >> n >> m; for (int i = 1; i <= n; i++) { scanf("\n"); for (int j = 1; j <= m; j++) scanf("%c", &ar[i][j]); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if ( j + 2 <= m && ar[i][j] == 'R' && ar[i][j + 1] == 'G' && ar[i][j + 2] == 'W' ) d[0][i][j] = ++sz; if ( i + 2 <= n && ar[i][j] == 'R' && ar[i + 1][j] == 'G' && ar[i + 2][j] == 'W') d[1][i][j] = ++sz; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if ( d[0][i][j] ) { if (d[1][i][j]) g[ d[0][i][j] ].pb( d[1][i][j] ), g[ d[1][i][j] ].pb( d[0][i][j] ); if (d[1][i - 1][j + 1]) g[ d[0][i][j] ].pb( d[1][i - 1][j + 1] ), g[ d[1][i - 1][j + 1] ].pb( d[0][i][j] ); if (d[1][i - 2][j + 2]) g[ d[0][i][j] ].pb( d[1][i - 2][j + 2] ), g[ d[1][i - 2][j + 2] ].pb( d[0][i][j] ); } if ( d[1][i][j] ) { if (d[0][i][j]) g[ d[1][i][j] ].pb( d[0][i][j] ), g[ d[0][i][j] ].pb( d[1][i][j] ); if (d[0][i + 1][j - 1]) g[ d[0][i + 1][j - 1] ].pb( d[1][i][j] ), g[ d[1][i][j] ].pb( d[0][i + 1][j - 1] ); if (d[0][i + 2][j - 2]) g[ d[0][i + 2][j - 2] ].pb( d[1][i][j] ), g[ d[1][i][j] ].pb( d[0][i + 2][j - 2] ); } } } for (int i = 1; i <= sz; i++) { if (u[i]) continue; wh = bl = 0; dfs(i, 0); ans += max( wh, bl ); } cout << ans << endl; }

Compilation message (stderr)

dango_maker.cpp:28:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() 
      ^
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("\n");
         ~~~~~^~~~~~
dango_maker.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%c", &ar[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...