Submission #471544

#TimeUsernameProblemLanguageResultExecution timeMemory
471544rainboyRetro (COCI17_retro)C11
0 / 100
120 ms1104 KiB
#include <stdio.h> #define N 300 #define M 300 int max(int a, int b) { return a > b ? a : b; } int main() { static char s[M + 1]; static int dp[M][N], dq[M][N]; int n, m, i, j, d, d_; scanf("%d%d", &n, &m); for (j = 0; j < m; j++) for (d = 0; d < n; d++) dp[j][d] = d == 0 ? 0 : -1; for (i = 0; i < n; i++) { scanf("%s", s); for (j = 0; j < m; j++) for (d = 0; d < n; d++) { if (s[j] == '*') dq[j][d] = d == 0 ? 0 : -1; else { d_ = s[j] == '.' || s[j] == 'M' ? d : (s[j] == '(' ? d + 1 : d - 1); dq[j][d] = -1; if (d_ >= 0 && d_ < n) { dq[j][d] = dp[j][d_]; if (j > 0 && dp[j - 1][d_] != -1) dq[j][d] = max(dq[j][d], dp[j - 1][d_]); if (j + 1 < m && dp[j + 1][d_] != -1) dq[j][d] = max(dq[j][d], dp[j + 1][d_]); } if (dq[j][d] != -1 && s[j] != '.' && s[j] != 'M') dq[j][d]++; } } for (j = 0; j < m; j++) for (d = 0; d < n; d++) dp[j][d] = dq[j][d]; } for (j = 0; j < m; j++) if (s[j] == 'M') { printf("%d\n", dp[j][0]); return 0; } return 0; }

Compilation message (stderr)

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