#include <stdio.h>
#define N 10
#define M 10
int dij[][3][2] = {
{ { 0, 1 }, { 1, 0 }, { 1, 1 } },
{ { 0, 1 }, { 0, 2 }, { 0, 3 } },
{ { 0, 1 }, { 1, 0 }, { 1, -1 } },
{ { 0, -1 }, { 1, 0 }, { 1, 1 } },
{ { -1, 0 }, { 0, -1 }, { 0, 1 } },
};
int rr[] = { 1, 2, 2, 2, 4 };
int main() {
static char cc[N][M + 1];
int n, m, t, r, h, i, j, k;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%s", cc[i]);
for (t = 0; t < 5; t++) {
k = 0;
for (r = 0; r < rr[t]; r++)
for (i = 0; i < n; i++)
for (j = 0; j < m; j++) {
int good;
if (cc[i][j] == '.')
continue;
good = 1;
for (h = 0; h < 3; h++) {
int i_, j_;
if (r == 0)
i_ = i + dij[t][h][0], j_ = j + dij[t][h][1];
else if (r == 1)
i_ = i - dij[t][h][1], j_ = j + dij[t][h][0];
else if (r == 2)
i_ = i - dij[t][h][0], j_ = j - dij[t][h][1];
else
i_ = i + dij[t][h][1], j_ = j - dij[t][h][0];
if (i_ < 0 || i_ >= n || j_ < 0 || j_ >= m || cc[i_][j_] != cc[i][j]) {
good = 0;
break;
}
}
if (good)
k++;
}
printf("%d\n", k);
}
return 0;
}
Compilation message
tetris.c: In function 'main':
tetris.c:20:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
tetris.c:22:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%s", cc[i]);
| ^~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
272 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |