Submission #237202

# Submission time Handle Problem Language Result Execution time Memory
237202 2020-06-05T08:41:42 Z DIvanCode Tetris (COCI17_tetris) C++14
80 / 80
5 ms 384 KB
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<ctime>
#include<cassert>
#include<complex>
#include<string>
#include<cstring>
#include<chrono>
#include<random>
#include<bitset>
#include<iomanip>

#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int N = 30;

int n, m;
char a[N][N];
int ans[N];

bool check1(int i, int j) {
	set<char> colors;
	vector<set<char>> vars;
	colors = {a[i][j], a[i - 1][j], a[i - 1][j + 1], a[i][j + 1]};
	vars.eb(colors);
	for (auto &colors : vars) {
		if (sz(colors) == 1) {
			return true;
		}
	}
	return false;
}

bool check2(int i, int j) {
	set<char> colors;
	vector<set<char>> vars;
	colors = {a[i][j], a[i][j + 1], a[i][j + 2], a[i][j + 3]};
	vars.eb(colors);
	colors = {a[i][j], a[i - 1][j], a[i - 2][j], a[i - 3][j]};
	vars.eb(colors);
	for (auto &colors : vars) {
		if (sz(colors) == 1) {
			return true;
		}
	}
	return false;
}

bool check3(int i, int j) {
	set<char> colors;
	vector<set<char>> vars;
	colors = {a[i][j], a[i][j + 1], a[i - 1][j + 1], a[i - 1][j + 2]};
	vars.eb(colors);
	colors = {a[i][j], a[i - 1][j], a[i - 1][j - 1], a[i - 2][j - 1]};
	vars.eb(colors);
	for (auto &colors : vars) {
		if (sz(colors) == 1) {
			return true;
		}
	}
	return false;
}

bool check4(int i, int j) {
	set<char> colors;
	vector<set<char>> vars;
	colors = {a[i][j], a[i][j + 1], a[i + 1][j + 1], a[i + 1][j + 2]};
	vars.eb(colors);
	colors = {a[i][j], a[i - 1][j], a[i - 1][j + 1], a[i - 2][j + 1]};
	vars.eb(colors);
	for (auto &colors : vars) {
		if (sz(colors) == 1) {
			return true;
		}
	}
	return false;
}

bool check5(int i, int j) {
	set<char> colors;
	vector<set<char>> vars;
	colors = {a[i][j], a[i + 1][j - 1], a[i + 1][j], a[i + 1][j + 1]};
	vars.eb(colors);
	colors = {a[i][j], a[i - 1][j - 1], a[i - 1][j], a[i - 1][j + 1]};
	vars.eb(colors);
	colors = {a[i][j], a[i - 1][j + 1], a[i][j + 1], a[i + 1][j + 1]};
	vars.eb(colors);
	colors = {a[i][j], a[i - 1][j - 1], a[i][j - 1], a[i + 1][j - 1]};
	vars.eb(colors);
	for (auto &colors : vars) {
		if (sz(colors) == 1) {
			return true;
		}
	}
	return false;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < N; ++i) {
		fill(a[i], a[i] + N, '#');
	}
	for (int i = 5; i <= n + 4; ++i) {
		for (int j = 5; j <= m + 4; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 5; i <= n + 4; ++i) {
		for (int j = 5; j <= m + 4; ++j) {
			if (a[i][j] == '.') continue;
			if (check1(i, j)) ans[1]++;
			if (check2(i, j)) ans[2]++;
			if (check3(i, j)) ans[3]++;
			if (check4(i, j)) ans[4]++;
			if (check5(i, j)) ans[5]++;
		}
	}
	for (int i = 1; i <= 5; ++i) {
		cout << ans[i] << "\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 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 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct