이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
* 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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |