Submission #165710

#TimeUsernameProblemLanguageResultExecution timeMemory
165710SenseiTetris (COCI17_tetris)C++17
80 / 80
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; int dirs[5][3][2] = { { {0, 1}, {1, 0}, {0, -1} }, { {0, 1}, {0, 1}, {0, 1} }, { {0, 1}, {-1, 0}, {0, 1} }, { {0, 1}, {1, 0}, {0, 1} }, { {0, 1}, {-1, 0}, {1, 1} } }; int cnt[5]; char st[12][12]; char st2[12][12]; int main () { int N, M; scanf("%d %d", &N, &M); for (int i = 1; i <= N; i++) { scanf("\n%s", st[i] + 1); } for (int rot = 0; rot < 4; rot++) { for (int si = 1; si <= N; si++) { for (int sj = 1; sj <= M; sj++) { if (st[si][sj] == '.') { continue; } for (int piece = 0; piece < 5; piece++) { int len = 0; int pi = si; int pj = sj; for (int pos = 0; pos < 4; pos++) { len++; if (pos == 3) { break; } int pi2 = pi + dirs[piece][pos][0]; int pj2 = pj + dirs[piece][pos][1]; if (pi2 < 1 || pi2 > N || pj2 < 1 || pj2 > M || st[pi][pj] != st[pi2][pj2]) { break; } pi = pi2; pj = pj2; } if (len == 4) { cnt[piece]++; } } } } for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { st2[j][N - i + 1] = st[i][j]; } } swap(N, M); for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { st[i][j] = st2[i][j]; } } } cout << cnt[0] / 4 << "\n"; cout << cnt[1] / 2 << "\n"; cout << cnt[2] / 2 << "\n"; cout << cnt[3] / 2 << "\n"; cout << cnt[4] << "\n"; return 0; }

Compilation message (stderr)

tetris.cpp: In function 'int main()':
tetris.cpp:40: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:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\n%s", st[i] + 1);
   ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...