Submission #234427

# Submission time Handle Problem Language Result Execution time Memory
234427 2020-05-24T07:59:02 Z NONAME Tetris (COCI17_tetris) C++17
72 / 80
5 ms 384 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;

int cnt[5], n, m;
string s[100];
bool mk[100][100];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> m;

	for (int i = 1; i <= n; i++)
		cin >> s[i], s[i] = "." + s[i] + ".";

    for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++) {
		if (mk[i][j] || s[i][j] == '.')
			continue;

		if (s[i][j] == s[i][j + 1] && s[i][j] == s[i + 1][j] && s[i][j] == s[i + 1][j + 1]) {
			cnt[0]++;
			mk[i][j] = mk[i + 1][j] = mk[i][j + 1] = mk[i + 1][j + 1] = 1;
			continue;
		}

		if (s[i][j] == s[i][j + 1] && s[i][j] == s[i][j + 2] && s[i][j] == s[i][j + 3]) {
			cnt[1]++;
			mk[i][j] = mk[i][j + 1] = mk[i][j + 2] = mk[i][j + 3] = 1;
			continue;
		}

		if (s[i][j] == s[i + 1][j] && s[i][j] == s[i + 2][j] && s[i][j] == s[i + 3][j]) {
			cnt[1]++;
			mk[i][j] = mk[i + 1][j] = mk[i + 2][j] = mk[i + 3][j] = 1;
			continue;
		}

		if (s[i][j] == s[i][j + 1] && s[i][j] == s[i + 1][j] && s[i][j] == s[i + 1][j - 1]) {
			cnt[2]++;
			mk[i][j] = mk[i][j + 1] = mk[i + 1][j] = mk[i + 1][j - 1] = 1;
			continue;
		}

		if (s[i][j] == s[i + 1][j] && s[i][j] == s[i + 1][j + 1] && s[i][j] == s[i + 2][j + 1]) {
			cnt[2]++;
			mk[i][j] = mk[i + 1][j] = mk[i + 1][j + 1] = mk[i + 2][j + 1] = 1;
			continue;
		}

		if (s[i][j] == s[i][j + 1] && s[i][j] == s[i + 1][j + 1] && s[i][j] == s[i + 1][j + 2]) {
			cnt[3]++;
			mk[i][j] = mk[i][j + 1] = mk[i + 1][j + 1] = mk[i + 1][j + 2] = 1;
			continue;
		}

		if (s[i][j] == s[i + 1][j] && s[i][j] == s[i + 1][j - 1] && s[i][j] == s[i + 2][j - 1]) {
			cnt[3]++;
			mk[i][j] = mk[i][j + 1] = mk[i + 1][j - 1] = mk[i + 2][j - 1] = 1;
			continue;
		}

		if (s[i][j] == s[i + 1][j - 1] && s[i][j] == s[i + 1][j] && s[i][j] == s[i + 1][j + 1]) {
			cnt[4]++;
			mk[i][j] = mk[i + 1][j - 1] = mk[i + 1][j] = mk[i + 1][j + 1] = 1;
			continue;
		}

		if (s[i][j] == s[i + 1][j] && s[i][j] == s[i + 2][j] && s[i][j] == s[i + 1][j + 1]) {
			cnt[4]++;
			mk[i][j] = mk[i + 1][j] = mk[i + 2][j] = mk[i + 1][j + 1] = 1;
			continue;
		}

		if (s[i][j] == s[i][j + 1] && s[i][j] == s[i][j + 2] && s[i][j] == s[i + 1][j + 1]) {
			cnt[4]++;
			mk[i][j] = mk[i][j + 1] = mk[i][j + 2] = mk[i + 1][j + 1] = 1;
			continue;
		}

		if (s[i][j] == s[i + 1][j] && s[i][j] == s[i + 2][j] && s[i][j] == s[i + 1][j - 1]) {
			cnt[4]++;
			mk[i][j] = mk[i + 1][j] = mk[i + 2][j] = mk[i + 1][j - 1] = 1;
			continue;
		}
	}

	for (int i = 0; i < 5; i++)
		cout << cnt[i] << el;
}

Compilation message

tetris.cpp: In function 'int main()':
tetris.cpp:32:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 1; i <= n; i++)
     ^~~
tetris.cpp:104:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i = 0; i < 5; i++)
  ^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Incorrect 5 ms 384 KB Output isn't correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct