Submission #661309

#TimeUsernameProblemLanguageResultExecution timeMemory
661309Trisanu_DasTetris (COCI17_tetris)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n, m, poss[12][12], v[7], x, y; char a[12][12]; int di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1}; int 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 && !ok[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 (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] != '.' && !ok[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 (stderr)

tetris.cpp:6:5: error: scalar object 'di' requires one element in initializer
    6 | int di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1};
      |     ^~
tetris.cpp:6:25: error: scalar object 'dj' requires one element in initializer
    6 | int di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1};
      |                         ^~
tetris.cpp: In function 'int dfs(int, int)':
tetris.cpp:10:107: error: 'ok' was not declared in this scope
   10 |   for (int t = 0; t < 4; t++)  if (i + di[t] > 0 && i + di[t] <= n && j + dj[t] > 0 && j + dj[t] <= m && !ok[i + di[t]][j + dj[t]] && a[i][j] == a[i + di[t]][j + dj[t]]) dfs(i + di[t], j+dj[t]);
      |                                                                                                           ^~
tetris.cpp:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | }
      | ^
tetris.cpp: In function 'int main()':
tetris.cpp:17:8: error: 'i' was not declared in this scope
   17 |   for (i = 1;i <= n; i++) for (j = 1;j <= m;j++) cin >> a[i][j];
      |        ^
tetris.cpp:17:32: error: 'j' was not declared in this scope
   17 |   for (i = 1;i <= n; i++) for (j = 1;j <= m;j++) cin >> a[i][j];
      |                                ^
tetris.cpp:18:8: error: 'i' was not declared in this scope
   18 |   for (i = 1;i <= n; i++)
      |        ^
tetris.cpp:19:12: error: 'j' was not declared in this scope
   19 |       for (j = 1; j <= m; j++)
      |            ^
tetris.cpp:20:34: error: 'ok' was not declared in this scope
   20 |           if (a[i][j] != '.' && !ok[i][j]){
      |                                  ^~
tetris.cpp:25:57: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                                                         ^
tetris.cpp:25:61: error: too few arguments to function 'int check(int, int)'
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                                                             ^
tetris.cpp:13:5: note: declared here
   13 | int check(int i, int j){return a[x][y] == a[x + i][y + j];}
      |     ^~~~~
tetris.cpp:25:74: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                                                                          ^
tetris.cpp:25:89: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                                                                                         ^
tetris.cpp:25:105: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                                                                                                         ^
tetris.cpp:25:110: error: too few arguments to function 'int check(int, int)'
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                                                                                                              ^
tetris.cpp:13:5: note: declared here
   13 | int check(int i, int j){return a[x][y] == a[x + i][y + j];}
      |     ^~~~~
tetris.cpp:25:119: error: expected ')' before ';' token
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                                                                  ~                                                    ^
      |                                                                                                                       )
tetris.cpp:25:119: error: expected ')' before ';' token
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                     ~                                                                                                 ^
      |                                                                                                                       )
tetris.cpp:25:119: error: expected ')' before ';' token
   25 |                 if ((check(0,1) && check(1,1) && check((1,2)) || (check((1,0) && check((1,-1) && check((2,-1))) v[4]++;
      |                    ~                                                                                                  ^
      |                                                                                                                       )
tetris.cpp:30:10: error: 'i' was not declared in this scope
   30 |     for (i = 1;i < 6; i++) cout << v[i] << '\n';
      |          ^