# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79947 | Just_Solve_The_Problem | Dango Maker (JOI18_dango_maker) | C++11 | 2 ms | 720 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 <bits/stdc++.h>
using namespace std;
const int N = (int)3e3 + 7;
int n, m;
char C[N][N];
int c[N][N];
int cost[N];
main() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++) {
getchar();
for (int j = 1; j <= m; j++) {
C[i][j] = getchar();
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (C[i][j] == 'G') {
c[i][j] = ((C[i][j - 1] == 'R' && C[i][j + 1] == 'W') || (C[i - 1][j] == 'R' && C[i + 1][j] == 'W'));
}
}
}
for (int i = 1; i <= n; i++) {
int x, y;
x = i;
y = 1;
int res = 0;
while (x >= 1 && y <= m) {
if (!c[x][y]) {
if (res) {
cost[i] += (res + 1) / 2;
res = 0;
}
} else {
res++;
}
x--;
y++;
}
cost[i] += (res + 1) / 2;
}
int ans = 0;
for (int i = 1; i <= n; i++) {
ans += cost[i];
}
memset(cost, 0, sizeof cost);
for (int i = 2; i <= m; i++) {
int x, y;
x = n;
y = i;
int res = 0;
while (x >= 1 && y <= m) {
if (!c[x][y]) {
if (res) {
cost[i] += (res + 1) / 2;
res = 0;
}
} else {
res++;
}
x--;
y++;
}
cost[i] += (res + 1) / 2;
}
for (int i = 1; i <= m; i++) {
ans += cost[i];
}
cout << ans;
}
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... |