Submission #165710

# Submission time Handle Problem Language Result Execution time Memory
165710 2019-11-28T11:13:19 Z Sensei Tetris (COCI17_tetris) C++17
80 / 80
2 ms 376 KB
#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

tetris.cpp: In function 'int main()':
tetris.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~~
tetris.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\n%s", st[i] + 1);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct