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