Submission #506375

#TimeUsernameProblemLanguageResultExecution timeMemory
506375sidonGrowing Vegetable is Fun 3 (JOI19_ho_t3)C++17
100 / 100
301 ms97164 KiB
#include <bits/stdc++.h> using namespace std; #define minim(X, Y) (X = min(X, Y)) #define F(X, Y) for(int X = 0; X < Y; X++) #define g(X) (X ? (X > 1 ? z : y) : x) const int Z = 202, INF = 1e9; int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z; int main() { cin >> N, getchar(); F(i, N) { char v = getchar(); A[i] = (v < 82) + (v < 89); } F(i, Z) F(j, Z) F(k, Z) F(l, 3) DP[i][j][k][l] = (i || j || k) ? INF : 0; F(i, N) { if(++c[A[i]] >= Z-1) break; p[A[i]][g(A[i]) = c[A[i]]] = i; F(j, 3) h[j][i] = c[j]; F(j, i+1) F(k, i+1) F(o, 3) { (A[i] ? x : y) = j; (A[i] < 2 ? z : y) = k; if(x > c[0] || y > c[1] || z > c[2]) continue; int &w = g(o), a = INF, b = 0; if(!w) continue; --w; F(r, 3) minim(a, r != o ? DP[x][y][z][r] : INF); ++w; F(r, 3) b += r != o ? max(0, g(r) - h[r][p[o][w]]) : 0; minim(DP[x][y][z][o], a + b); } } int res = INF; F(i, 3) minim(res, DP[c[0]][c[1]][c[2]][i]); cout << (res == INF ? -1 : res); }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:31:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |    if(!w) continue; --w;
      |    ^~
joi2019_ho_t3.cpp:31:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |    if(!w) continue; --w;
      |                     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...