# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234381 | Vimmer | Tetris (COCI17_tetris) | C++14 | 6 ms | 384 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>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
#define sz(x) ll(x.size())
#define base 1000000
#define M ll(1e9+7)
#define N 100005
#define F first
#define S second
#define pb push_back
#define in insert
#define eb emplace_back
#define ed "\n"
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int kol[5];
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
string s[n];
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 (0 <= s[i][j] - 'A' && s[i][j] - 'A' < 26) s[i][j] = char('a' + s[i][j] - 'A');
bool mk[n][m];
memset(mk, 0, sizeof(mk));
bool f = 1;
while (f)
{
f = 0;
int xs, ys;
for (int i = 0; i < n && !f; i++)
for (int j = 0; j < m && !f; j++)
if (!mk[i][j] && s[i][j] != '.') {f = 1; xs = i; ys = j; break;}
if (!f) break;
bool fr = 1;
for (int j = ys; j < ys + 4; j++)
if (j >= m || s[xs][j] != s[xs][ys]) fr = 0;
if (fr) {kol[1]++; for (int j = ys; j < ys + 4; j++) mk[xs][j] = 1; continue;}
fr = 1;
for (int i = xs; i < xs + 4; i++)
if (i >= n || s[i][ys] != s[xs][ys]) fr = 0;
if (fr) {kol[1]++; for (int i = xs; i < xs + 4; i++) mk[i][ys] = 1; continue;}
if (xs + 1 < n && ys - 1 >= 0 && ys + 1 < m && s[xs][ys] == s[xs + 1][ys] && s[xs + 1][ys - 1] == s[xs][ys] && s[xs][ys] == s[xs + 1][ys + 1])
{
mk[xs][ys] = 1; mk[xs + 1][ys] = 1; mk[xs + 1][ys - 1] = 1; mk[xs + 1][ys + 1] = 1;
kol[4]++;
continue;
}
if (xs + 1 < n && ys + 1 < m && s[xs][ys] == s[xs + 1][ys] && s[xs][ys] == s[xs + 1][ys + 1] && s[xs][ys] == s[xs][ys + 1])
{
mk[xs][ys] = 1; mk[xs + 1][ys] = 1; mk[xs + 1][ys + 1] = 1; mk[xs][ys + 1] = 1;
kol[0]++;
continue;
}
if (xs + 1 < n && ys + 1 < m && ys - 1 >= 0 && s[xs][ys] == s[xs][ys + 1] && s[xs][ys] == s[xs + 1][ys] && s[xs][ys] == s[xs + 1][ys - 1])
{
mk[xs][ys] = 1; mk[xs][ys + 1] = 1; mk[xs + 1][ys] = 1; mk[xs + 1][ys - 1] = 1;
kol[2]++;
continue;
}
if (xs + 1 < n && ys + 2 < m && s[xs][ys] == s[xs][ys + 1] && s[xs][ys] == s[xs + 1][ys + 1] && s[xs][ys] == s[xs + 1][ys + 2])
{
mk[xs][ys] = 1; mk[xs][ys + 1] = 1; mk[xs + 1][ys + 1] = 1; mk[xs + 1][ys + 2] = 1;
kol[3]++;
continue;
}
if (xs + 2 < n && ys - 1 >= 0 && s[xs][ys] == s[xs + 1][ys] && s[xs][ys] == s[xs + 1][ys - 1] && s[xs][ys] == s[xs + 2][ys - 1])
{
mk[xs][ys] = 1; mk[xs + 1][ys] = 1; mk[xs + 1][ys - 1] = 1; mk[xs + 2][ys - 1] = 1;
kol[3]++;
continue;
}
if (xs + 2 < n && ys + 1 < m && s[xs][ys] == s[xs + 1][ys] && s[xs][ys] == s[xs + 1][ys + 1] && s[xs][ys] == s[xs + 2][ys + 1])
{
mk[xs][ys] = 1; mk[xs + 1][ys] = 1; mk[xs + 1][ys + 1] = 1; mk[xs + 2][ys + 1] = 1;
kol[2]++;
continue;
}
if (xs + 2 < n && ys - 1 >= 0 && s[xs][ys] == s[xs + 1][ys] && s[xs + 1][ys - 1] == s[xs][ys] && s[xs][ys] == s[xs + 2][ys])
{
mk[xs][ys] = 1; mk[xs + 1][ys] = 1; mk[xs + 1][ys - 1] = 1; mk[xs + 2][ys] = 1;
kol[4]++;
continue;
}
if (xs + 1 < n && ys + 2 < m && s[xs][ys] == s[xs][ys + 1] && s[xs + 1][ys + 1] == s[xs][ys] && s[xs][ys] == s[xs][ys + 2])
{
mk[xs][ys] = 1; mk[xs][ys + 1] = 1; mk[xs + 1][ys + 1] = 1; mk[xs][ys + 2] = 1;
kol[4]++;
continue;
}
if (xs + 2 < n && ys + 1 < m && s[xs][ys] == s[xs + 1][ys + 1] && s[xs + 1][ys] == s[xs][ys] && s[xs][ys] == s[xs + 2][ys])
{
mk[xs][ys] = 1; mk[xs + 1][ys + 1] = 1; mk[xs + 1][ys] = 1; mk[xs + 2][ys] = 1;
kol[4]++;
continue;
}
}
for (int i = 0; i < 5; i++) cout << kol[i] << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |