제출 #585269

#제출 시각아이디문제언어결과실행 시간메모리
585269Dan4Life웜뱃 (IOI13_wombats)C++17
55 / 100
20090 ms104044 KiB
#include "wombats.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define pb push_back #define fi first #define se second const int INF = (int)1e9; const int maxn = 1000010; vector<pair<int,int>> adj[maxn]; int dis[maxn], ind[5002][202]; int h[5002][202], v[5002][202], dp[5002][202]; bool vis[maxn]; int n, m; int pref(int i, int j, int k){ if(j==k) return 0; int ans = 0; if(j>k) swap(j,k); for(int l = j; l < k; l++) ans+=h[i][l]; return ans; } int dijkstra(int s, int d){ for(int i = 0; i <= n*m; i++) dis[i]=INF, vis[i] = 0; priority_queue<pii,vector<pii>,greater<pii>> pq; pq.push({0,s}); dis[s] = 0; while(!pq.empty()){ int a = pq.top().se; pq.pop(); if(vis[a]) continue; vis[a] = 1; for(auto u : adj[a]){ int b = u.fi, w = u.se; if(dis[b]>dis[a]+w){ dis[b] = dis[a]+w; pq.push({dis[b], b}); } } } return dis[d]; } void init(int R, int C, int H[5000][200], int V[5000][200]) { int _ = 0; n = R, m = C; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) ind[i][j] = _++; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(j<m-1){ int x = ind[i][j], y = ind[i][j+1]; adj[x].pb({y, H[i][j]}); adj[y].pb({x, H[i][j]}); h[i][j] = H[i][j]; } if(i<n-1){ int x = ind[i][j], y = ind[i+1][j]; adj[x].pb({y, V[i][j]}); v[i][j] = V[i][j]; } } } } void changeH(int P, int Q, int W) { h[P][Q]=W; return; int x = ind[P][Q], y = ind[P][Q+1]; for(auto &u : adj[x]) if(u.fi==y) u.se=W; for(auto &u : adj[y]) if(u.fi==x) u.se=W; } void changeV(int P, int Q, int W) { int x = ind[P][Q], y = ind[P+1][Q]; v[P][Q]=W; return; for(auto &u : adj[x]) if(u.fi==y) u.se=W; for(auto &u : adj[y]) if(u.fi==x) u.se=W; } int escape(int V1, int V2) { dp[0][V1] = 0; for(int x = V1-1; x>=0; x--) dp[0][x] = dp[0][x+1]+h[0][x]; for(int x = V1+1; x<m; x++) dp[0][x] = dp[0][x-1]+h[0][x-1]; for(int i = 1; i < n; i++){ for(int j = 0; j < m; j++){ dp[i][j] = INF; for(int k = 0; k < m; k++) dp[i][j] = min(dp[i][j], dp[i-1][k]+pref(i,j,k)+v[i-1][k]); } } return dp[n-1][V2]; //return dijkstra(ind[0][V1], ind[n-1][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;
      |      ^~~
wombats.cpp: In function 'int pref(int, int, int)':
wombats.cpp:17:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   17 |     if(j==k) return 0; int ans = 0;
      |     ^~
wombats.cpp:17:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   17 |     if(j==k) return 0; int ans = 0;
      |                        ^~~
wombats.cpp: In function 'int dijkstra(int, int)':
wombats.cpp:29:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   29 |         if(vis[a]) continue; vis[a] = 1;
      |         ^~
wombats.cpp:29:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |         if(vis[a]) continue; vis[a] = 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...