Submission #1067791

#TimeUsernameProblemLanguageResultExecution timeMemory
1067791sleepntsheepWombats (IOI13_wombats)C++17
39 / 100
2835 ms17340 KiB
#include "wombats.h" #include <algorithm> #include <cstring> #include <vector> using namespace std; template <typename T> using ve = vector<T>; int r, c, at[9999], h[5000][200], v[5000][200]; int sum = 0; int c_is_2_dp(int V1, int V2) { static int dp[5001][2]; dp[0][V1] = 0; dp[0][!V1] = h[0][0]; for (int i = 1; i < r; ++i) { dp[i][0] = dp[i - 1][0] + v[i - 1][0]; dp[i][1] = dp[i - 1][1] + v[i - 1][1]; dp[i][0] = min(dp[i][0], dp[i][1] + h[i][0]); dp[i][1] = min(dp[i][1], dp[i][0] + h[i][0]); } return dp[r - 1][V2]; } void changeH(int P, int Q, int W) { if (c == 2) { h[P][Q] = W; } /* ... */ } void changeV(int P, int Q, int W) { if (c == 1) { sum += W - at[P]; at[P] = W; } else if (c == 2) { v[P][Q] = W; } /* ... */ } static int floyd[401][401]; void init(int R, int C, int H[5000][200], int V[5000][200]) { r = R, c = C; if (c == 1) for (int i = 0; i < r; ++i) changeV(i, 0, V[i][0]); else if (c == 2) { for (int i = 0; i < r; ++i) { if (i + 1 < r) changeV(i, 0, V[i][0]), changeV(i, 1, V[i][1]); changeH(i, 0, H[i][0]); } } else if (r <= 20 and c <= 20) { auto id = [&](int p, int q) { return p * c + q; }; memset(floyd, 63, sizeof floyd); for (int i = 0; i < r * c; ++i) floyd[i][i] = 0; for (int i = 0; i + 1 < r; ++i) for (int j = 0; j < c; ++j) { int u = id(i, j), v = id(i + 1, j); floyd[u][v] = min(floyd[u][v], V[i][j]); } for (int i = 0 ; i < r; ++i) for (int j = 0; j + 1 < c; ++j) { int u = id(i, j), v = id(i, j + 1); floyd[u][v] = min(floyd[u][v], H[i][j]); floyd[v][u] = min(floyd[v][u], H[i][j]); } for (int bruh=3;bruh--;)for(int i=0;i<r*c;++i)for(int j=0;j<r*c;++j)for(int k=0;k<r*c;++k) floyd[i][j]=min(floyd[i][j],floyd[i][k]+floyd[k][j]); } } int escape(int V1, int V2) { if (c == 1) return sum; else if (c == 2) return c_is_2_dp(V1, V2); return floyd[V1][c * (r - 1) + V2]; }

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
#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...