Submission #1197246

#TimeUsernameProblemLanguageResultExecution timeMemory
1197246aykhnDango Maker (JOI18_dango_maker)C++20
13 / 100
0 ms528 KiB
#include <bits/stdc++.h>

using namespace std;

#define inf 0x3F3F3F3F

const int MXN = 3e3 + 5;

char a[MXN][MXN];
int used[MXN][MXN];

void _()
{
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j];
  auto check1 = [&](int x, int y)
  {
    if (y + 2 >= m) return false;
    return !used[x][y] && !used[x][y + 1] && !used[x][y + 2] && a[x][y] == 'R' && a[x][y + 1] == 'G' && a[x][y + 2] == 'W';
  };
  auto check2 = [&](int x, int y)
  {
    if (x + 2 >= n) return false;
    return !used[x][y] && !used[x + 1][y] && !used[x + 2][y] && a[x][y] == 'R' && a[x + 1][y] == 'G' && a[x + 2][y] == 'W';
  };
  int res = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if (check1(i, j)) used[i][j] = used[i][j + 1] = used[i][j + 2] = 1, res++;
    }
  }
  for (int j = 0; j < m; j++)
  {
    for (int i = 0; i < n; i++)
    {
      if (check2(i, j)) used[i][j] = used[i + 1][j] = used[i + 2][j], res++;
    }
  }
  cout << res << '\n';
}

signed main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) _();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...