제출 #516370

#제출 시각아이디문제언어결과실행 시간메모리
516370600Mihnea웜뱃 (IOI13_wombats)C++17
55 / 100
20065 ms42928 KiB
#include "wombats.h" #include <bits/stdc++.h> using namespace std; const int N = 5000 + 7; const int M = 200 + 7; const int INF = (int) 1e9 + 7; int H[N][M]; int V[N][M]; int n; int m; struct Node { int l; int r; int cost[M][M]; Node() : l(0), r(0) { for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) cost[i][j] = INF; } }; Node* getSmall(int l, int r) { Node* solution = new Node; solution->l = l; solution->r = r; for (int start = 0; start < m; start++) { solution->cost[start][start] = 0; for (int col = 1; col < m; col++) { solution->cost[start][col] = min(solution->cost[start][col], solution->cost[start][col - 1] + H[0][col - 1]); } for (int col = m - 2; col >= 0; col--){ solution->cost[start][col] = min(solution->cost[start][col], solution->cost[start][col + 1] + H[0][col]); } } for (int row = l + 1; row <= r; row++) { /// add row j for (int start = 0; start < m; start++) { for (int col = 0; col < m; col++) { solution->cost[start][col] += V[row - 1][col]; } for (int col = 1; col < m; col++) { solution->cost[start][col] = min(solution->cost[start][col], solution->cost[start][col - 1] + H[row][col - 1]); } for (int col = m - 2; col >= 0; col--){ solution->cost[start][col] = min(solution->cost[start][col], solution->cost[start][col + 1] + H[row][col]); } } } // exit(0); return solution; } Node* update(Node* node, int pos) { node = getSmall(0, n - 1); return node; } Node* build(int l, int r) { Node* node = getSmall(l, r); return node; } Node* root; void init(int R, int C, int Hinit[5000][200], int Vinit[5000][200]) { for (int i = 0; i < R; i++) for (int j = 0; j < C; j++) H[i][j] = Hinit[i][j], V[i][j] = Vinit[i][j]; n = R; m = C; root = build(0, n - 1); /* ... */ } void changeH(int P, int Q, int W) { /* ... */ H[P][Q] = W; root = update(root, P); } void changeV(int P, int Q, int W) { /* ... */ V[P][Q] = W; root = update(root, P); } int escape(int V1, int V2) { return root->cost[V1][V2]; }

컴파일 시 표준 에러 (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...