Submission #44581

#TimeUsernameProblemLanguageResultExecution timeMemory
44581heonTetris (COCI17_tetris)C++11
16 / 80
2 ms584 KiB
#include<stdio.h> int main() { int n, m; int fig1 = 0, fig2 = 0, fig3 = 0, fig4 = 0, fig5 = 0; scanf("%d %d", &n, &m); char niz[10][10]; for (int i = 0; i < n; i++) { scanf("%s", &niz[i]); } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (niz[i][j] == '.') { continue; } if (i + 1 < n && j+1 < m && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i][j + 1] && niz[i][j] == niz[i + 1][j + 1]) { fig1++; } if (i + 3 < n && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i + 2][j] && niz[i][j] == niz[i + 3][j] && niz[i][j] == niz[i + 4][j]) { fig2++; } if (j + 3 < m && niz[i][j] == niz[i][j + 1] && niz[i][j] == niz[i][j + 2] && niz[i][j] == niz[i][j + 3] && niz[i][j] == niz[i][j + 4]) { fig2++; } if (i + 2 < n && j + 1 < m && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i - 1][j + 1] && niz[i][j] == niz[i][j + 1]) { fig3++; } if (i + 1 < n && j + 1 < m && j > 0 && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i][j + 1] && niz[i][j] == niz[i + 1][j - 1]) { fig3++; } if (i + 2 < n && j + 1 < m && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i + 1][j + 1] && niz[i][j] == niz[i + 2][j + 1]) { fig4++; } if (i + 2 < n && j + 2 < m && niz[i][j] == niz[i + 1][j - 1] && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i][j + 1]) { fig4++; } if (i+2 < n && j > 0 && niz[i+1][j-1] == niz[i][j] && niz[i+1][j] == niz[i][j] && niz[i+2][j] == niz[i][j]) { fig5++; } if (i+1 < n && j > 0 && j+1 < m && niz[i][j] == niz[i - 1][j] && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i][j - 1]) { fig5++; } if (i+1 < n && j+2 < m && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i][j - 1] && niz[i][j] == niz[i][j + 1]) { fig5++; } if (i+1 < n && j+2 < m && niz[i][j] == niz[i - 1][j] && niz[i][j] == niz[i + 1][j] && niz[i][j] == niz[i][j - 1]) { fig5++; } } } printf("%d\n%d\n%d\n%d\n%d\n", fig1, fig2, fig3, fig4, fig5); }

Compilation message (stderr)

tetris.cpp: In function 'int main()':
tetris.cpp:10:22: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[10]' [-Wformat=]
   scanf("%s", &niz[i]);
               ~~~~~~~^
tetris.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
tetris.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", &niz[i]);
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...