# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165710 | Sensei | Tetris (COCI17_tetris) | C++17 | 2 ms | 376 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;
int dirs[5][3][2] = {
{
{0, 1},
{1, 0},
{0, -1}
},
{
{0, 1},
{0, 1},
{0, 1}
},
{
{0, 1},
{-1, 0},
{0, 1}
},
{
{0, 1},
{1, 0},
{0, 1}
},
{
{0, 1},
{-1, 0},
{1, 1}
}
};
int cnt[5];
char st[12][12];
char st2[12][12];
int main () {
int N, M;
scanf("%d %d", &N, &M);
for (int i = 1; i <= N; i++) {
scanf("\n%s", st[i] + 1);
}
for (int rot = 0; rot < 4; rot++) {
for (int si = 1; si <= N; si++) {
for (int sj = 1; sj <= M; sj++) {
if (st[si][sj] == '.') {
continue;
}
for (int piece = 0; piece < 5; piece++) {
int len = 0;
int pi = si;
int pj = sj;
for (int pos = 0; pos < 4; pos++) {
len++;
if (pos == 3) {
break;
}
int pi2 = pi + dirs[piece][pos][0];
int pj2 = pj + dirs[piece][pos][1];
if (pi2 < 1 || pi2 > N || pj2 < 1 || pj2 > M || st[pi][pj] != st[pi2][pj2]) {
break;
}
pi = pi2;
pj = pj2;
}
if (len == 4) {
cnt[piece]++;
}
}
}
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
st2[j][N - i + 1] = st[i][j];
}
}
swap(N, M);
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
st[i][j] = st2[i][j];
}
}
}
cout << cnt[0] / 4 << "\n";
cout << cnt[1] / 2 << "\n";
cout << cnt[2] / 2 << "\n";
cout << cnt[3] / 2 << "\n";
cout << cnt[4] << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |