Submission #661314

# Submission time Handle Problem Language Result Execution time Memory
661314 2022-11-25T13:23:47 Z Trisanu_Das Tetris (COCI17_tetris) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
int n, m, poss[12][12], v[7], x, y;
char a[12][12];
int di[4] = {-1, 1, 0, 0}, dj[4] = {0, 0, -1, 1};
 
void dfs(int i, int j){
  poss[i][j] = 1;
  for (int t = 0; t < 4; t++)  if (i + di[t] > 0 && i + di[t] <= n && j + dj[t] > 0 && j + dj[t] <= m && !poss[i + di[t]][j + dj[t]] && a[i][j] == a[i + di[t]][j + dj[t]]) dfs(i + di[t], j+dj[t]);
}
 
int check(int i, int j){return a[x][y] == a[x + i][y + j];}
 
int main(){
  cin >> n >> m;
  for (int i = 1;i <= n; i++) for (int j = 1;j <= m;j++) cin >> a[i][j];
  for (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';
}

Compilation message

tetris.cpp: In function 'int main()':
tetris.cpp:18:8: error: expected primary-expression before 'for'
   18 |   for (for i = 1;i <= n; i++)
      |        ^~~
tetris.cpp:18:18: error: 'i' was not declared in this scope; did you mean 'di'?
   18 |   for (for i = 1;i <= n; i++)
      |                  ^
      |                  di
tetris.cpp:19:12: error: 'j' was not declared in this scope; did you mean 'dj'?
   19 |       for (j = 1; j <= m; j++)
      |            ^
      |            dj
tetris.cpp:29:10: error: 'i' was not declared in this scope; did you mean 'di'?
   29 |     for (i = 1;i < 6; i++) cout << v[i] << '\n';
      |          ^
      |          di