# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234421 | NONAME | Tetris (COCI17_tetris) | C++17 | 0 ms | 0 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>
#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 = 0; i < n; i++)
cin >> s[i];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
if (mk[i][j] || s[i][j] == '.')
continue;
if (i + 1 < n && j + 1 < m && 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 (j + 3 < m && 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 (i + 3 < n && 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 (i + 1 < n && j - 1 >= 0 && j + 1 < m && 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 (i + 2 < n && j + 1 < m && 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 (i + 1 < n && j + 2 < m && 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 (i + 2 < n && j - 1 >= 0 && 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 (i + 1 < n && j + 1 < m && j - 1 >= 0 && s[i][j] != s[i][j + 1] && c[i][j] == s[i + 1][j] && s[i][j] == s[i + 1][j - 1] && 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 (i + 1 < n && j - 1 >= 0 && j + 1 < m && 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 (i + 2 < n && j + 1 < m && 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 (i + 1 < n && j + 2 < m && 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 (i + 2 < n && j - 1 >= 0 && 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;
}