Submission #411641

#TimeUsernameProblemLanguageResultExecution timeMemory
411641albertolg101Wombats (IOI13_wombats)C++17
0 / 100
20078 ms32076 KiB
#include <bits/stdc++.h> #include "wombats.h" using namespace std; using pii = pair<long long, long long>; const long long INF = 1e12; int n, m; vector<vector<long long>> h(5001, vector<long long> (201)), v = h, dp = h; bool sol = false; void init(int R, int C, int H[5000][200], int V[5000][200]) { n = R, m = C; for(int i = 0 ; i < R ; i++) { for(int j = 0 ; j < C - 1 ; j++) { h[i][j] = H[i][j]; } } for(int i = 0 ; i < R - 1 ; i++) { for(int j = 0 ; j < C ; j++) { v[i][j] = V[i][j]; } } } void changeH(int P, int Q, int W) { h[P][Q] = W; sol = false; } void changeV(int P, int Q, int W) { v[P][Q] = W; sol = false; } int escape(int V1, int V2) { for(int i = 0 ; i < m ; i++) { dp[n-1][i] = INF; } dp[n-1][V2] = 0; for(int i = n - 1 ; i >= 0 ; i--) { set<pii> s; for(int j = 0 ; j < m ; j++) s.insert({dp[i][j], j}); while(s.size()) { long long j, dist, dist2; tie(dist, j) = *s.begin(); dist2 = dist; s.erase(s.begin()); if(dp[i][j] < dist) continue; for(int k = j + 1 ; k < m ; k++) { if(dp[i][k] > dist + h[i][k-1]) { dp[i][k] = dist + h[i][k-1]; dist += h[i][k-1]; } else break; } for(int k = j - 1 ; k >= 0 ; k--) { dist2 += h[i][k]; if(dp[i][k] > dist2 + h[i][k]) { dp[i][k] = dist2 + h[i][k]; } else break; } } for(int j = 0 ; j < m and i != 0; j++) { dp[i-1][j] = dp[i][j] + v[i-1][j]; } } /* for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j < m - 1; j++) { cout << h[i][j] << ' ' ; } cout << endl ; } cout << endl ; for(int i = 0 ; i < n - 1 ; i++) { for(int j = 0 ; j < m ; j++) { cout << v[i][j] << ' ' ; } cout << endl ; } cout << endl ; for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j < m ; j++) { cout << dp[i][j] << ' ' ; } cout << endl; } */ return dp[0][V1]; }

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...