/*
* The way if it's all predetermined
* And the way i should go all my life
* I swear to go wherever will be
* 'Cause there'll be something to see and to find
*/
#include "bits/stdc++.h"
#define ll long long
using namespace std;
#define check(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename val1>
void __f(const char* name, val1&& value) {
cout << name << " = " << value << endl;
}
template <typename val1, typename... values>
void __f( const char* names, val1&& value, values&&... multiplevalue)
{
const char* comma = strchr( names + 1, ','); cout.write(names, comma - names) << " = " << value << " "; __f(comma + 1, multiplevalue...);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , m;
cin >> n >> m;
char s[1001][1001];
bool done[1001][1001];
for(int i = 0;i<n;i++){
for(int j = 0;j<m;j++){
cin >> s[i][j];
done[i][j] = false;
}
}
auto checks = [&] (int i,int j){
int c1 = 0 , c2 = 0;
if(s[i][j]=='R' and s[i][j+1]=='G' and s[i][j+2]=='W' and done[i][j]==done[i][j+1] and done[i][j+2]==done[i][j] and done[i][j]==false)
c1++;
if(s[i+1][j]=='R' and s[i+1][j+1]=='G' and s[i+1][j+2]=='W' and done[i+1][j]==done[i+1][j+1] and done[i+1][j+2]==done[i+1][j] and done[i+1][j]==false)
c1++;
if(s[i+2][j]=='R' and s[i+2][j+1]=='G' and s[i+2][j+2]=='W' and done[i+2][j]==done[i+2][j+1] and done[i+2][j+2]==done[i+2][j] and done[i+2][j]==false)
c1++;
//
if(s[i][j]=='R' and s[i+1][j]=='G' and s[i+2][j]=='W' and done[i][j]==done[i+1][j] and done[i][j]==done[i+2][j] and done[i][j]==false)
c2++;
if(s[i][j+1]=='R' and s[i+1][j+1]=='G' and s[i+2][j+1]=='W' and done[i][j+1]==done[i+1][j+1] and done[i][j+1]==done[i+2][j+1] and done[i][j+1]==false)
c2++;
if(s[i][j+2]=='R' and s[i+1][j+2]=='G' and s[i+2][j+2]=='W' and done[i][j+2]==done[i+1][j+2] and done[i][j+2]==done[i+2][j+2] and done[i][j+2]==false)
c2++;
if(c1 > c2){
if(s[i][j]=='R' and s[i][j+1]=='G' and s[i][j+2]=='W')
{
done[i][j] = 1;
done[i][j+1] = 1;
done[i][j+2] = 1;
}
if(s[i+1][j]=='R' and s[i+1][j+1]=='G' and s[i+1][j+2]=='W')
{
done[i+1][j] = 1;
done[i+1][j+1] = 1;
done[i+1][j+2] = 1;
}
if(s[i+2][j]=='R' and s[i+2][j+1]=='G' and s[i+2][j+2]=='W')
{
done[i+2][j] = 1;
done[i+2][j+1] = 1;
done[i+2][j+2] = 1;
}
} else {
if(s[i][j]=='R' and s[i+1][j]=='G' and s[i+2][j]=='W')
{
done[i][j] = done[i+1][j] = done[i+2][j] = 1;
}
if(s[i][j+1]=='R' and s[i+1][j+1]=='G' and s[i+2][j+1]=='W')
{
done[i][j+1] = done[i+1][j+1] = done[i+2][j+1] = 1;
}
if(s[i][j+2]=='R' and s[i+1][j+2]=='G' and s[i+2][j+2]=='W')
{
done[i][j+2] = done[i+1][j+2] = done[i+2][j+2] = 1;
}
}
return max(c1 , c2);
};
int ans = 0;
for(int i = 0;i<n;i++){
for(int j = 0;j<m;j++){
if(i+2 < n and j+2 < m)
ans += checks(i,j);
}
}
cout << ans;
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2252 KB |
Output is correct |
2 |
Correct |
1 ms |
2268 KB |
Output is correct |
3 |
Correct |
1 ms |
2252 KB |
Output is correct |
4 |
Correct |
1 ms |
2252 KB |
Output is correct |
5 |
Correct |
1 ms |
2252 KB |
Output is correct |
6 |
Correct |
1 ms |
2252 KB |
Output is correct |
7 |
Correct |
1 ms |
2252 KB |
Output is correct |
8 |
Correct |
1 ms |
2252 KB |
Output is correct |
9 |
Correct |
1 ms |
2252 KB |
Output is correct |
10 |
Incorrect |
1 ms |
2252 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2252 KB |
Output is correct |
2 |
Correct |
1 ms |
2268 KB |
Output is correct |
3 |
Correct |
1 ms |
2252 KB |
Output is correct |
4 |
Correct |
1 ms |
2252 KB |
Output is correct |
5 |
Correct |
1 ms |
2252 KB |
Output is correct |
6 |
Correct |
1 ms |
2252 KB |
Output is correct |
7 |
Correct |
1 ms |
2252 KB |
Output is correct |
8 |
Correct |
1 ms |
2252 KB |
Output is correct |
9 |
Correct |
1 ms |
2252 KB |
Output is correct |
10 |
Incorrect |
1 ms |
2252 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2252 KB |
Output is correct |
2 |
Correct |
1 ms |
2268 KB |
Output is correct |
3 |
Correct |
1 ms |
2252 KB |
Output is correct |
4 |
Correct |
1 ms |
2252 KB |
Output is correct |
5 |
Correct |
1 ms |
2252 KB |
Output is correct |
6 |
Correct |
1 ms |
2252 KB |
Output is correct |
7 |
Correct |
1 ms |
2252 KB |
Output is correct |
8 |
Correct |
1 ms |
2252 KB |
Output is correct |
9 |
Correct |
1 ms |
2252 KB |
Output is correct |
10 |
Incorrect |
1 ms |
2252 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |