Submission #564102

#TimeUsernameProblemLanguageResultExecution timeMemory
564102SeDunionDango Maker (JOI18_dango_maker)C++17
13 / 100
3 ms3856 KiB
#include <iostream> #include <cassert> #include <algorithm> #include <string> #include <bitset> #include <vector> #include <cmath> #include <deque> #include <queue> #include <stack> #include <map> #include <set> #ifndef LOCAL #include <bits/stdc++.h> #define cerr if(false)cerr #endif using namespace std; using ll = long long; const int M = 222; const int N = M*M*3 + 66; vector<pair<int,int>>v1,v2; int a[M][M]; int id1(int x, int y) { return x * M + y; } int id2(int x, int y) { return x * M + y + M*M; } int u12[N], used[N]; vector<int>g[N]; void dfs(int v, int &x, int &y) { used[v] = 1; x++; for (int to : g[v]) if (!used[to]) { dfs(to, y, x); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1 ; i <= n ; ++ i) { for (int j = 1 ; j <= m ; ++ j) { char c; cin >> c; if (c == 'R') a[i][j] = 0; else if (c == 'G') a[i][j] = 1; else a[i][j] = 2; } } for (int i = 1 ; i + 2 <= n ; ++ i) { for (int j = 1 ; j <= m ; ++ j) { if (a[i][j] == 0 && a[i + 1][j] == 1 && a[i + 2][j] == 2) { cerr << i << " " << j << " v1\n"; u12[id1(i, j)] = 1; v1.emplace_back(i, j); } } } for (int i = 1 ; i <= n ; ++ i) { for (int j = 1 ; j + 2 <= m ; ++ j) { if (a[i][j] == 0 && a[i][j + 1] == 1 && a[i][j + 2] == 2) { cerr << i << " " << j << " v2\n"; u12[id2(i, j)] = 1; v2.emplace_back(i, j); } } } for (auto [x1, y1] : v1) { for (auto [x2, y2] : v2) { if (x1 <= x2 && x2 <= x1 + 2 && y2 <= y1 && y1 <= y2 + 2) { cerr << x1 << " " << y1 << " | " << x2 << " " << y2 << endl; g[id1(x1,y1)].emplace_back(id2(x2,y2)); g[id2(x2,y2)].emplace_back(id1(x1,y1)); } } } int ans = 0; for (int i = 0 ; i < N ; ++ i) { if (!u12[i] || used[i]) continue; int x = 0, y = 0; dfs(i, x, y); ans += max(x, y); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...