Submission #164434

#TimeUsernameProblemLanguageResultExecution timeMemory
1644346arenTetris (COCI17_tetris)C++14
80 / 80
14 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define all(s) s.begin(), s.end() #define vi vector<int> #define pb push_back #define ii pair<int, int> #define x first #define y second bool check[15][15]; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; int cnt[10]; int n, m; string s[15]; void bfs(int u, int v, char color) { int x = u, y = v, xx = u, yy = v; queue<ii> q; q.push({u, v}); check[u][v] = 1; while (!q.empty()) { ii o = q.front(); q.pop(); for (int i = 0; i < 4; i++) { int uu = o.x + dx[i]; int vv = o.y + dy[i]; if (!check[uu][vv] && s[uu][vv] == color) { q.push({uu, vv}); check[uu][vv] = 1; x = min(x, uu); y = min(y, vv); xx = max(xx, uu); yy = max(yy, vv); } } } if (x == xx || y == yy) cnt[2]++; else if (xx - x == 1 && yy - y == 1) cnt[1]++; else if (xx - x == 1 && yy - y) { if (s[xx][yy] == color && s[x][y] == color) cnt[4]++; else if (s[xx][y] == color && s[x][yy] == color) cnt[3]++; else cnt[5]++; } else { if (s[x][y] == color && s[xx][yy] == color) cnt[3]++; else if (s[x][yy] == color && s[xx][y] == color) cnt[4]++; else cnt[5]++; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> s[i]; s[i] = " " + s[i]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (!check[i][j] && s[i][j] != '.') { bfs(i, j, s[i][j]); } } } for (int i = 1; i <= 5; i++) { cout << cnt[i] << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...