제출 #405669

#제출 시각아이디문제언어결과실행 시간메모리
405669rainboyPaint By Numbers (IOI16_paint)C11
100 / 100
323 ms42444 KiB
#include "paint_c.h" #define N 200000 #define K 100 void solve_puzzle(int n, char *aa, int k, int *ll, char *cc) { static char dp[N + 1][K + 1], dq[N + 1][K + 1], can_w[N + 1]; static int pp[N], can_b[N + 1]; int h, i, l; for (i = 0; i < n; i++) pp[i] = aa[i] == '_' ? i : (i == 0 ? -1 : pp[i - 1]); dp[0][0] = 1; for (i = 1; i <= n; i++) for (h = 0; h <= k; h++) { l = h == 0 ? -1 : ll[h - 1]; dp[i][h] = aa[i - 1] != 'X' && dp[i - 1][h] || h > 0 && pp[i - 1] < i - l && (i == l ? h == 1 : aa[i - 1 - l] != 'X' && dp[i - 1 - l][h - 1]); } dq[n][k] = 1; for (i = n - 1; i >= 0; i--) for (h = k; h >= 0; h--) { l = h == k ? -1 : ll[h]; dq[i][h] = aa[i] != 'X' && dq[i + 1][h] || h < k && i + l <= n && pp[i + l - 1] < i && (i + l == n ? h == k - 1 : aa[i + l] != 'X' && dq[i + l + 1][h + 1]); } for (i = 0; i < n; i++) for (h = 0; h <= k; h++) if (dp[i][h] && dq[i + 1][h]) { can_w[i] = 1; break; } for (h = 0; h < k; h++) { l = ll[h]; for (i = 0; i + l <= n; i++) if (pp[i + l - 1] < i && (i == 0 ? h == 0 : aa[i - 1] != 'X' && dp[i - 1][h]) && (i + l == n ? h == k - 1 : aa[i + l] != 'X' && dq[i + l + 1][h + 1])) can_b[i]++, can_b[i + l]--; } for (i = 1; i <= n; i++) can_b[i] += can_b[i - 1]; for (i = 0; i < n; i++) cc[i] = aa[i] == '.' ? (can_w[i] && can_b[i] ? '?' : (can_w[i] ? '_' : 'X')) : aa[i]; }

컴파일 시 표준 에러 (stderr) 메시지

paint.c: In function 'solve_puzzle':
paint.c:17:32: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   17 |    dp[i][h] = aa[i - 1] != 'X' && dp[i - 1][h] || h > 0 && pp[i - 1] < i - l && (i == l ? h == 1 : aa[i - 1 - l] != 'X' && dp[i - 1 - l][h - 1]);
      |               ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
paint.c:23:28: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   23 |    dq[i][h] = aa[i] != 'X' && dq[i + 1][h] || h < k && i + l <= n && pp[i + l - 1] < i && (i + l == n ? h == k - 1 : aa[i + l] != 'X' && dq[i + l + 1][h + 1]);
      |               ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...