# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
543174 | rainboy | Dijamant (COCI22_dijamant) | C11 | 122 ms | 35572 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 <stdio.h>
#define N 2000
#define M 2000
int main() {
static char cc[N][M + 1];
static int ll[N][M], rr[N][M];
int n, m, i, i_, i1, j, cnt, good;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%s", cc[i]);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++)
ll[i][j] = cc[i][j] == '#' ? j : (j == 0 ? -1 : ll[i][j - 1]);
for (j = m - 1; j >= 0; j--)
rr[i][j] = cc[i][j] == '#' ? j : (j + 1 == m ? m : rr[i][j + 1]);
}
cnt = 0;
for (j = 0; j < m; j++)
for (i_ = -1, i = 0; i < n; i++)
if (cc[i][j] == '#') {
if (i_ == -1 || (i - i_) % 2 != 0 || j - (i - i_) / 2 < 0 || j + (i - i_) / 2 >= m)
good = 0;
else {
good = 1;
for (i1 = i_; i1 * 2 <= i + i_; i1++)
if (ll[i1][j] != j - (i1 - i_) || rr[i1][j] != j + (i1 - i_)
|| ll[i + i_ - i1][j] != j - (i1 - i_) || rr[i + i_ - i1][j] != j + (i1 - i_)) {
good = 0;
break;
}
}
if (good)
cnt++;
i_ = i;
}
printf("%d\n", cnt);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |