This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <string.h>
#include <numeric>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
#define ll long long
#define ld long double
const int MX = 3005;
const ll mod = 1e9 + 7;
const ll inv2 = (mod + 1) / 2;
int n, m;
string s[MX];
int main(){
cin.tie(0) -> sync_with_stdio(0);
cin >> n >> m;
for(int i = 0; i < n; i ++)
cin >> s[i];
int ans = 0, hor = 0, ver = 0, non = 0;
for(int diag = 0; diag <= n + m - 2; diag ++){
int x = min(diag, n - 1), y = diag - x;
hor = 0, ver = 0, non = 0;
for(; 0 <= x && x < n && 0 <= y && y < m; x --, y ++){
int tp = non;
non = max({hor, ver, non});
if(y > 0 && y < m - 1 && s[x][y - 1] == 'R' && s[x][y] == 'G' && s[x][y + 1] == 'W')
hor = max(hor, tp) + 1;
if(x > 0 && x < n - 1 && s[x - 1][y] == 'R' && s[x][y] == 'G' && s[x + 1][y] == 'W')
ver = max(ver, tp) + 1;
}
ans += max({hor, ver, non});
}
cout << ans << endl;
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... |