#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));
}
}
}
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 time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3796 KB |
Output is correct |
2 |
Correct |
3 ms |
3800 KB |
Output is correct |
3 |
Correct |
2 ms |
3796 KB |
Output is correct |
4 |
Correct |
2 ms |
3796 KB |
Output is correct |
5 |
Correct |
3 ms |
3892 KB |
Output is correct |
6 |
Correct |
3 ms |
3804 KB |
Output is correct |
7 |
Correct |
2 ms |
3804 KB |
Output is correct |
8 |
Correct |
3 ms |
3796 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
3796 KB |
Output is correct |
11 |
Correct |
2 ms |
3796 KB |
Output is correct |
12 |
Correct |
2 ms |
3796 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Correct |
4 ms |
3796 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
3796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3796 KB |
Output is correct |
2 |
Correct |
3 ms |
3800 KB |
Output is correct |
3 |
Correct |
2 ms |
3796 KB |
Output is correct |
4 |
Correct |
2 ms |
3796 KB |
Output is correct |
5 |
Correct |
3 ms |
3892 KB |
Output is correct |
6 |
Correct |
3 ms |
3804 KB |
Output is correct |
7 |
Correct |
2 ms |
3804 KB |
Output is correct |
8 |
Correct |
3 ms |
3796 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
3796 KB |
Output is correct |
11 |
Correct |
2 ms |
3796 KB |
Output is correct |
12 |
Correct |
2 ms |
3796 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Correct |
4 ms |
3796 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
3796 KB |
Output is correct |
17 |
Correct |
3 ms |
3804 KB |
Output is correct |
18 |
Correct |
2 ms |
3796 KB |
Output is correct |
19 |
Correct |
2 ms |
3796 KB |
Output is correct |
20 |
Incorrect |
2 ms |
3800 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3796 KB |
Output is correct |
2 |
Correct |
3 ms |
3800 KB |
Output is correct |
3 |
Correct |
2 ms |
3796 KB |
Output is correct |
4 |
Correct |
2 ms |
3796 KB |
Output is correct |
5 |
Correct |
3 ms |
3892 KB |
Output is correct |
6 |
Correct |
3 ms |
3804 KB |
Output is correct |
7 |
Correct |
2 ms |
3804 KB |
Output is correct |
8 |
Correct |
3 ms |
3796 KB |
Output is correct |
9 |
Correct |
2 ms |
3796 KB |
Output is correct |
10 |
Correct |
3 ms |
3796 KB |
Output is correct |
11 |
Correct |
2 ms |
3796 KB |
Output is correct |
12 |
Correct |
2 ms |
3796 KB |
Output is correct |
13 |
Correct |
3 ms |
3796 KB |
Output is correct |
14 |
Correct |
4 ms |
3796 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
3796 KB |
Output is correct |
17 |
Correct |
3 ms |
3804 KB |
Output is correct |
18 |
Correct |
2 ms |
3796 KB |
Output is correct |
19 |
Correct |
2 ms |
3796 KB |
Output is correct |
20 |
Incorrect |
2 ms |
3800 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |