Submission #476120

#TimeUsernameProblemLanguageResultExecution timeMemory
476120rainboyClickbait (COCI18_clickbait)C11
120 / 120
5 ms2212 KiB
#include <stdio.h> #define N 1000 #define M 1000 char cc[N][M + 1]; int n, m; void dfs(int i, int j, int dir) { if (dir == -2) { int i_, j1, j2, a, b; j1 = j; while (j1 > 0 && cc[i][j1 - 1] != '.') j1--; j2 = j; while (j2 + 1 < m && cc[i][j2 + 1] != '.') j2++; i_ = i + 1; while (i_ + 1 < n && cc[i_ + 1][j1] != '.') i_++; for (a = i_ - 1; a >= i + 1; a--) { if (j1 > 0 && cc[a][j1 - 1] != '.') dfs(a, j1 - 1, -1); if (j2 + 1 < m && cc[a][j2 + 1] != '.') dfs(a, j2 + 1, 1); } for (a = i + 1; a <= i_ - 1; a++) for (b = j1 + 1; b <= j2 - 1; b++) if (cc[a][b] != '.') printf("%c", cc[a][b]); printf("\n"); } else { if (cc[i][j] == '-') dfs(i, j + dir, dir ? dir : -2); else if (cc[i][j] == '|' || dir) dfs(i + 1, j, 0); else { dir = j > 0 && cc[i][j - 1] == '-' ? -1 : 1; dfs(i, j + dir, dir); } } } int main() { int i, j; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%s", cc[i]); for (i = 0; i < n; i++) for (j = 0; j < m; j++) if (cc[i][j] != '.') { dfs(i, j, -2); return 0; } return 0; }

Compilation message (stderr)

clickbait.c: In function 'main':
clickbait.c:47:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
clickbait.c:49:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |   scanf("%s", cc[i]);
      |   ^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...