Submission #786061

#TimeUsernameProblemLanguageResultExecution timeMemory
786061MODDIWombats (IOI13_wombats)C++14
16 / 100
20050 ms9412 KiB
#include "wombats.h" #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define pii pair<int,int> #define ll long long map<pair<pii,pii>, int> cost; int r, c; void init(int R, int C, int H[5000][200], int V[5000][200]) { r = R; c = C; for(int i = 0; i < R; i++) { for(int j = 0; j < C-1; j++){ cost[mp(mp(i,j), mp(i,j+1))] = H[i][j]; } } for(int i = 0; i < R-1; i++){ for(int j = 0; j < C; j++){ cost[mp(mp(i,j), mp(i+1, j))] = V[i][j]; // cout<<"COST: "<<i<<" "<<j<<" to "<<i+1<<" "<<j<<" is "<<V[i][j]<<endl; } } } void changeH(int P, int Q, int W) { cost[mp(mp(P,Q), mp(P,Q+1))] = W; } void changeV(int P, int Q, int W) { cost[mp(mp(P,Q), mp(P+1, Q))] = W; } int escape(int V1, int V2) { ll dist[r][c]; for(int i = 0; i < r; i++) for(int j = 0; j < c; j++) dist[i][j] = 1e15; dist[0][V1] = 0; priority_queue<pair<int, pii> > pq; pq.push(mp(0, mp(0, V1))); while(!pq.empty()){ pii at = pq.top().second; pq.pop(); int x = at.first, y = at.second; // cout<<x<<" "<<y<<" "<<dist[x][y]<<endl; if(y - 1 >= 0 && dist[x][y-1] > dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))]){ dist[x][y-1] = dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))]; pq.push(mp(-dist[x][y-1], mp(x,y-1))); } if(y+1 < c && dist[x][y+1] > dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))]){ dist[x][y+1] = dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))]; pq.push(mp(-dist[x][y+1], mp(x,y+1))); } // cout<<dist[x+1][y]<<" "<<dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]<<endl; if(x + 1 < r && dist[x+1][y] > dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]){ dist[x+1][y] = dist[x][y] + cost[mp(mp(x,y), mp(x+1, y))]; pq.push(mp(-dist[x+1][y], mp(x+1, y))); } } return dist[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...