# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
627152 | boris_mihov | Dango Maker (JOI18_dango_maker) | C++17 | 1 ms | 340 KiB |
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 <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
typedef long long llong;
const int MAXN = 3000 + 10;
const int INF = 1e9;
int n, m;
char s[MAXN][MAXN];
bool used[MAXN][MAXN];
inline bool tryHorizontal(int stX, int stY)
{
if (stY + 2 >= m+1) return false;
return !used[stX][stY] && !used[stX][stY + 1] && !used[stX][stY + 2] && s[stX][stY] == 'R' && s[stX][stY + 1] == 'G' && s[stX][stY + 2] == 'W';
}
inline bool tryVertical(int stX, int stY)
{
if (stX + 2 >= n+1) return false;
return !used[stX][stY] && !used[stX + 1][stY] && !used[stX + 2][stY] && s[stX][stY] == 'R' && s[stX + 1][stY] == 'G' && s[stX + 2][stY] == 'W';
}
void solve()
{
int ans = 0;
for (int row = 1 ; row <= n ; ++row)
{
for (int col = 1 ; col <= m ; ++col)
{
if (tryHorizontal(row, col))
{
used[row][col] = true;
used[row][col + 1] = true;
used[row][col + 2] = true;
ans++;
}
}
for (int col = 1 ; col <= m ; ++col)
{
if (tryVertical(row, col))
{
used[row][col] = true;
used[row + 1][col] = true;
used[row + 2][col] = true;
ans++;
}
}
}
std::cout << ans << '\n';
}
void read()
{
std::cin >> n >> m;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> s[i]+1;
}
}
void fastIO()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIO();
read();
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |