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 <bits/stdc++.h>
using ll = long long;
inline void fastio() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
}
ll n, m, ans;
std::string s[3030];
std::vector<ll> ver, hor;
int main() {
fastio();
std::cin >> n >> m;
for (ll i = 0; i < n; i++) {
std::cin >> s[i];
}
for (ll i = 0; i < n + m; i++) {
ver = std::vector<ll>();
hor = std::vector<ll>();
for (ll j = 0; j < n; j++) {
ll k = i - j;
if (k < 0 or k >= m) continue;
if (s[j][k] == 'R') {
if (j < n - 2 and s[j + 1][k] == 'G' and s[j + 2][k] == 'W') {
ver.emplace_back(j);
ans++;
}
if (k < m - 2 and s[j][k + 1] == 'G' and s[j][k + 2] == 'W') {
hor.emplace_back(j);
ans++;
}
}
}
for (auto x = ver.begin(), y = hor.begin(); x < ver.end() and y < hor.end();) {
if (*y - *x < 0) {
y++;
} else if (*y - *x > 2) {
x++;
} else {
ans--;
x++, y++;
}
}
}
std::cout << ans;
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... |