#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int used[3005][3005], n, m;
char A[3005][3005];
inline int conv(int x, int y){
return (x - 1) * m + y;
}
int massiveskewer(int x, int y){
if(A[x][y] == 'G')return 0;
if(A[x][y] == 'R'){
if(x + 4 > n || y <= 2)return 0;
if(A[x+1][y] != 'G')return 0;
if(A[x+2][y] != 'W')return 0;
if(A[x+1][y-1] != 'R')return 0;
if(A[x+2][y-1] != 'G')return 0;
if(A[x+3][y-1] != 'W')return 0;
if(A[x+2][y-2] != 'R')return 0;
if(A[x+3][y-2] != 'G')return 0;
if(A[x+4][y-2] != 'W')return 0;
int tmp = 3;
for(int i = y; i >= y - 2; i--){
bool f = 1;
for(int j = x + (y - i); j <= x + (y - i) + 2; j++){
if(used[j][i])f = 0;
}
if(!f)tmp--;
else for(int j = x + (y - i); j <= x + (y - i) + 2; j++){
used[j][i] = 1;
}
}
//cout << x << ' ' << y << ' ' << tmp << '\n';
return tmp;
}
if(x + 2 > n || y <= 4)return 0;
if(A[x][y-1] != 'G')return 0;
if(A[x][y-2] != 'R')return 0;
if(A[x+1][y-1] != 'W')return 0;
if(A[x+1][y-2] != 'G')return 0;
if(A[x+1][y-3] != 'R')return 0;
if(A[x+2][y-2] != 'W')return 0;
if(A[x+2][y-3] != 'G')return 0;
if(A[x+2][y-4] != 'R')return 0;
int tmp = 3;
for(int i = x; i <= x + 2; i++){
bool f = 1;
for(int j = y - (i - x); j >= y - (i - x) - 2; j--){
if(used[i][j])f = 0;
}
if(!f)tmp--;
else for(int j = y - (i - x); j >= y - (i - x) - 2; j--){
used[i][j] = 1;
}
}
//cout << x << ' ' << y << ' ' << tmp << '\n';
return tmp;
}
inline bool check(int x, int y){
if(A[x][y] != 'R')return 0;
if(used[x][y])return 0;
if(x + 2 <= n && !used[x+1][y] && !used[x+2][y] && A[x+1][y] == 'G' && A[x+2][y] == 'W'){
used[x][y] = used[x+1][y] = used[x+2][y] = 1;
return 1;
}
if(y + 2 <= n && !used[x][y+1] && !used[x][y+2] && A[x][y+1] == 'G' && A[x][y+2] == 'W'){
used[x][y] = used[x][y+1] = used[x][y+2] = 1;
return 1;
}
return 0;
}
void solve(){
cin >> n >> m;
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin >> A[i][j];
int ans = 0;
for(int i = 1; i <= n; i++){
for(int j = m; j >= 1; j--){
ans += massiveskewer(i, j);
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(check(i, j))ans++;
}
}
cout << ans;
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
for(int tc1=1;tc1<=tc;tc1++){
// cout << "Case #" << tc1 << ": ";
solve();
}
}
Compilation message
dango_maker.cpp:102:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
102 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |