Submission #58740

#TimeUsernameProblemLanguageResultExecution timeMemory
58740YaDon4ickDango Maker (JOI18_dango_maker)C++14
13 / 100
4 ms760 KiB
//By Don4ick #define _GLIBCXX_DEBUG #include <bits/stdc++.h> typedef long long ll; typedef long double ld; typedef unsigned int ui; #define forn(i, n) for (int i = 1; i <= n; i++) #define pb push_back #define all(x) x.begin(), x.end() #define y1 qwer1234 const double PI = acos(-1.0); const int DIR = 4; const int X[] = {1, 0, -1, 0}; const int Y[] = {0, 1, 0, -1}; const int N = 3005; const int M = N * N * 2; using namespace std; bitset < M > was; int n, m, cnt0, cnt1; string s[N]; void dfs(int x, int y, int type) { int v = x * m + y + type * n * m; was[v] = true; if (type == 0) { cnt0++; if (x < n - 2 && s[x + 1][y] == 'G' && s[x + 2][y] == 'W') { int u = x * m + y + n * m; if (!was[u]) dfs(x, y, 1); } if (x < n - 1 && x > 0 && s[x - 1][y + 1] == 'R' && s[x + 1][y + 1] == 'W') { int tx = x - 1, ty = y + 1; int u = tx * m + ty + n * m; if (!was[u]) dfs(tx, ty, 1); } if (x > 1 && s[x - 2][y + 2] == 'R' && s[x - 1][y + 2] == 'G') { int tx = x - 2, ty = y + 2; int u = tx * m + ty + n * m; if (!was[u]) dfs(tx, ty, 1); } } else { cnt1++; if (y < n - 2 && s[x][y + 1] == 'G' && s[x][y + 2] == 'W') { int tx = x, ty = y; int u = tx * m + ty; if (!was[u]) dfs(tx, ty, 0); } if (y < n - 1 && y > 0 && s[x + 1][y - 1] == 'R' && s[x + 1][y + 1] == 'W') { int tx = x + 1, ty = y - 1; int u = tx * m + ty; if (!was[u]) dfs(tx, ty, 0); } if (y > 1 && s[x + 2][y - 2] == 'R' && s[x + 2][y - 1] == 'G') { int tx = x + 2, ty = y - 2; int u = tx * m + ty; if (!was[u]) dfs(tx, ty, 0); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); //~read cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; //~solve int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m - 2; j++) { int v = i * m + j; if (s[i][j] == 'R' && s[i][j + 1] == 'G' && s[i][j + 2] == 'W' && !was[v]) { cnt0 = cnt1 = 0; dfs(i, j, 0); ans += max(cnt0, cnt1); } } } for (int i = 0; i < n - 2; i++) { for (int j = 0; j < m; j++) { int v = i * m + j + n * m; if (s[i][j] == 'R' && s[i + 1][j] == 'G' && s[i + 2][j] == 'W' && !was[v]) { cnt0 = cnt1 = 0; dfs(i, j, 1); ans += max(cnt0, cnt1); } } } //~result cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...