#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;
const ll maxn=3e3+5;
const int INF=1e9;
#define ok ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define endl '\n'
int n, m, ls, ans, ans2;
bool use[maxn][maxn];
char grid[maxn][maxn];
int main() {
ok
cin >> n >> m;
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
cin >> grid[i][j];
}
}
for(int i=0; i<n; i++) {
for(int j=0; j<m-2; j++) {
if(grid[i][j]=='R' && grid[i][j+1]=='G' && grid[i][j+2]=='W' && !use[i][j] && !use[i][j+1] && !use[i][j+2]) {
ans++;
use[i][j]=1;
use[i][j+1]=1;
use[i][j+2]=1;
}
}
if(ls<m) {
for(int j=0; j<n-2; j++) {
if(grid[j][ls]=='R' && grid[j+1][ls]=='G' && grid[j+2][ls]=='W' && !use[j][ls] && !use[j+1][ls] && !use[j+2][ls]) {
ans++;
use[j][ls]=1;
use[j+1][ls]=1;
use[j+2][ls]=1;
}
}
ls++;
}
}
for(int i=ls; i<m; i++) {
for(int j=0; j<n-2; j++) {
if(grid[j][ls]=='R' && grid[j+1][ls]=='G' && grid[j+2][ls]=='W' && !use[j][ls] && !use[j+1][ls] && !use[j+2][ls]) {
ans++;
use[j][ls]=1;
use[j+1][ls]=1;
use[j+2][ls]=1;
}
}
}
ls=0;
memset(use, 0, sizeof use);
for(int i=0; i<m; i++) {
for(int j=0; j<n-2; j++) {
if(grid[j][i]=='R' && grid[j+1][i]=='G' && grid[j+2][i]=='W' && !use[j][i] && !use[j+1][i] && !use[j+2][i]) {
ans2++;
use[j][i]=1;
use[j+1][i]=1;
use[j+2][i]=1;
}
}
if(ls<n) {
for(int j=0; j<m-2; j++) {
if(grid[ls][j]=='R' && grid[ls][j+1]=='G' && grid[ls][j+2]=='W' && !use[ls][j] && !use[ls][j+1] && !use[ls][j+2]) {
ans2++;
use[ls][j]=1;
use[ls][j+1]=1;
use[ls][j+2]=1;
}
}
ls++;
}
}
for(int i=ls; i<n; i++) {
for(int j=0; j<m-2; j++) {
if(grid[i][j]=='R' && grid[i][j+1]=='G' && grid[i][j+2]=='W' && !use[i][j] && !use[i][j+1] && !use[i][j+2]) {
ans2++;
use[i][j]=1;
use[i][j+1]=1;
use[i][j+2]=1;
}
}
}
cout << max(ans, ans2);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9044 KB |
Output is correct |
2 |
Correct |
4 ms |
9044 KB |
Output is correct |
3 |
Correct |
4 ms |
9044 KB |
Output is correct |
4 |
Correct |
4 ms |
9044 KB |
Output is correct |
5 |
Correct |
4 ms |
9172 KB |
Output is correct |
6 |
Correct |
4 ms |
9044 KB |
Output is correct |
7 |
Correct |
4 ms |
9156 KB |
Output is correct |
8 |
Correct |
4 ms |
9164 KB |
Output is correct |
9 |
Correct |
4 ms |
9044 KB |
Output is correct |
10 |
Correct |
4 ms |
9172 KB |
Output is correct |
11 |
Correct |
4 ms |
9172 KB |
Output is correct |
12 |
Correct |
4 ms |
9172 KB |
Output is correct |
13 |
Correct |
4 ms |
9160 KB |
Output is correct |
14 |
Correct |
4 ms |
9044 KB |
Output is correct |
15 |
Correct |
4 ms |
9172 KB |
Output is correct |
16 |
Correct |
4 ms |
9044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9044 KB |
Output is correct |
2 |
Correct |
4 ms |
9044 KB |
Output is correct |
3 |
Correct |
4 ms |
9044 KB |
Output is correct |
4 |
Correct |
4 ms |
9044 KB |
Output is correct |
5 |
Correct |
4 ms |
9172 KB |
Output is correct |
6 |
Correct |
4 ms |
9044 KB |
Output is correct |
7 |
Correct |
4 ms |
9156 KB |
Output is correct |
8 |
Correct |
4 ms |
9164 KB |
Output is correct |
9 |
Correct |
4 ms |
9044 KB |
Output is correct |
10 |
Correct |
4 ms |
9172 KB |
Output is correct |
11 |
Correct |
4 ms |
9172 KB |
Output is correct |
12 |
Correct |
4 ms |
9172 KB |
Output is correct |
13 |
Correct |
4 ms |
9160 KB |
Output is correct |
14 |
Correct |
4 ms |
9044 KB |
Output is correct |
15 |
Correct |
4 ms |
9172 KB |
Output is correct |
16 |
Correct |
4 ms |
9044 KB |
Output is correct |
17 |
Correct |
4 ms |
9172 KB |
Output is correct |
18 |
Correct |
4 ms |
9172 KB |
Output is correct |
19 |
Incorrect |
4 ms |
9172 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9044 KB |
Output is correct |
2 |
Correct |
4 ms |
9044 KB |
Output is correct |
3 |
Correct |
4 ms |
9044 KB |
Output is correct |
4 |
Correct |
4 ms |
9044 KB |
Output is correct |
5 |
Correct |
4 ms |
9172 KB |
Output is correct |
6 |
Correct |
4 ms |
9044 KB |
Output is correct |
7 |
Correct |
4 ms |
9156 KB |
Output is correct |
8 |
Correct |
4 ms |
9164 KB |
Output is correct |
9 |
Correct |
4 ms |
9044 KB |
Output is correct |
10 |
Correct |
4 ms |
9172 KB |
Output is correct |
11 |
Correct |
4 ms |
9172 KB |
Output is correct |
12 |
Correct |
4 ms |
9172 KB |
Output is correct |
13 |
Correct |
4 ms |
9160 KB |
Output is correct |
14 |
Correct |
4 ms |
9044 KB |
Output is correct |
15 |
Correct |
4 ms |
9172 KB |
Output is correct |
16 |
Correct |
4 ms |
9044 KB |
Output is correct |
17 |
Correct |
4 ms |
9172 KB |
Output is correct |
18 |
Correct |
4 ms |
9172 KB |
Output is correct |
19 |
Incorrect |
4 ms |
9172 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |