# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238169 | 74TrAkToR | Tetris (COCI17_tetris) | C++17 | 5 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>
using namespace std;
char a[12][12];
int used[12][12];
int ans[5];
vector < pair < int, int > > go = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
vector < pair < int, int > > Q;
map < vector < pair < int, int > >, int > t = {
{{{0, 0}, {0, 1}, {1, 0}, {1, 1}}, 0},
{{{0, 0}, {0, 1}, {0, 2}, {0, 3}}, 1},
{{{0, 0}, {1, 0}, {2, 0}, {3, 0}}, 1},
{{{0, 0}, {1, 0}, {0, 1}, {1, -1}}, 2},
{{{0, 0}, {0, 1}, {1, 1}, {1, 2}}, 3},
{{{0, 0}, {1, 0}, {1, 1}, {2, 1}}, 2},
{{{0, 0}, {1, 0}, {1, -1}, {2, -1}}, 3}
};
void dfs(int i, int j) {
Q.push_back({i, j});
used[i][j] = 1;
for (auto u : go) {
i += u.first, j += u.second;
if (used[i][j] == 0 && a[i][j] == a[i - u.first][j - u.second]) {
dfs(i, j);
}
i -= u.first, j -= u.second;
}
}
main() {
#ifdef HOME
//freopen("input.txt", "r", stdin);
#endif // HOME
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i <= 11; ++i) {
for (int j = 0; j <= 11; ++j) a[i][j] = '.';
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) cin >> a[i][j];
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (a[i][j] != '.' && used[i][j] == 0) {
Q = {};
dfs(i, j);
assert((int)Q.size() == 4);
int oksik = 4;
for (int pos = 3; pos >= 0; --pos) Q[pos].first -= Q[0].first, Q[pos].second -= Q[0].second;
for (int pos = 0; pos < 24; ++pos) {
if (t.find(Q) != t.end()) oksik = t[Q];
if (pos != 23) next_permutation(Q.begin(), Q.end());
}
ans[oksik]++;
}
}
}
for (int i = 0; i <= 4; ++i) cout << ans[i] << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |