Submission #661316

#TimeUsernameProblemLanguageResultExecution timeMemory
661316Trisanu_DasTetris (COCI17_tetris)C++17
80 / 80
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; int n, m, poss[12][12], v[7], i, j; char a[12][12]; int di[4] = {-1, 1, 0, 0}, dj[4] = {0, 0, -1, 1}; void dfs(int x, int y){ poss[x][y] = 1; for (int t = 0; t < 4; t++) if (x + di[t] > 0 && x + di[t] <= n && y + dj[t] > 0 && y + dj[t] <= m && !poss[x + di[t]][y + dj[t]] && a[x][y] == a[x + di[t]][y + dj[t]]) dfs(x + di[t], y+dj[t]); } int check(int x, int y){return a[i][j] == a[x + i][y + j];} int main(){ cin >> n >> m; for (i = 1;i <= n; i++) for (j = 1;j <= m;j++) cin >> a[i][j]; for (i = 1;i <= n; i++) for (j = 1; j <= m; j++) if (a[i][j] != '.' && !poss[i][j]){ dfs(i,j); if (check(0,1) && check(1,0) && check(1,1)) v[1]++; if ((check(0,1) && check(0,2) && check(0,3)) || (check(1,0) && check(2,0) && check(3,0))) v[2]++; if ((check(0,1) && check(1,0) && check(1,-1)) || (check(1,0) && check(1,1) && check(2,1))) v[3]++; if ((check(0,1) && check(1,1) && check(1,2)) || (check(1,0) && check(1,-1) && check(2,-1))) v[4]++; if ((check(1,-1) && check(1,0) && check(1,1)) || (check(1,-1) && check(1,0) && check(2,0)) || (check(0,1) && check(0,2) && check(1,1)) || (check(1,0) && check(1,1) && check(2,0))) v[5]++; } for (i = 1;i < 6; i++) cout << v[i] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...