Submission #237193

#TimeUsernameProblemLanguageResultExecution timeMemory
237193MlxaTetris (COCI17_tetris)C++14
80 / 80
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define all(x) x.begin(), x.end() #define x first #define y second #define mp make_pair #define mt make_tuple const int N = 100; int n; int m; char s[N][N]; bool used[N][N]; bool ok(int i, int j) { return 0 <= i && i < n && 0 <= j && j < m; } int h; int is; int js; void dfs(int i, int j) { int di = i - is; int dj = j - js; h += di * di * di + 100 * dj * dj + dj; used[i][j] = true; auto check = [&](int ni, int nj) { if (ok(ni, nj) && s[ni][nj] == s[i][j] && !used[ni][nj]) { dfs(ni, nj); } }; check(i - 1, j); check(i + 1, j); check(i, j - 1); check(i, j + 1); } int cnt[5]; signed main() { #ifdef LC assert(freopen("input.txt", "r", stdin)); #endif ios::sync_with_stdio(0); cin.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 (s[i][j] == '.' || used[i][j]) { continue; } is = i; js = j; h = 0; dfs(i, j); if (h == 204) { ++cnt[0]; } else if (h == 1406 || h == 36) { ++cnt[1]; } else if (h == 202 || h == 212) { ++cnt[2]; } else if (h == 606 || h == 208) { ++cnt[3]; } else { ++cnt[4]; } } } for (int i = 0; i < 5; ++i) { cout << cnt[i] << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...