Submission #962231

#TimeUsernameProblemLanguageResultExecution timeMemory
962231serkanrashidWombats (IOI13_wombats)C++14
37 / 100
20101 ms21060 KiB
#include "wombats.h" #include <bits/stdc++.h> using namespace std; struct edge { int x,y; long long dist; edge(){}; edge(int xi, int yi, long long di) { x = xi; y = yi; dist = di; } bool operator<(const edge&ed) const { return dist>ed.dist; } }; int r,c; int h[5000][200],v[5000][200]; unsigned int d[5000][200],inf = -1; int sum; void changeH(int P, int Q, int W) { h[P][Q] = W; } void changeV(int P, int Q, int W) { sum -= v[P][Q]; v[P][Q] = W; sum += W; } int escape(int V1, int V2) { if(c==1) return sum; memset(d,-1,sizeof(d)); priority_queue<edge>q; d[0][V1] = 0; q.push({0,V1,0}); edge e,nb; while(!q.empty()) { e = q.top(); q.pop(); if(e.dist<=d[e.x][e.y]) { ///LEFT nb = {0,0,inf}; if(e.y>0) nb = {e.x,e.y-1,h[e.x][e.y-1]}; if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y]) { nb.dist += e.dist; d[nb.x][nb.y] = nb.dist; q.push(nb); } ///RIGHT nb = {0,0,inf}; if(e.y<c-1) nb = {e.x,e.y+1,h[e.x][e.y]}; if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y]) { nb.dist += e.dist; d[nb.x][nb.y] = nb.dist; q.push(nb); } ///DOWN nb = {0,0,inf}; if(e.x<r-1) nb = {e.x+1,e.y,v[e.x][e.y]}; if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y]) { nb.dist += e.dist; d[nb.x][nb.y] = nb.dist; q.push(nb); } } } int pom = d[r-1][V2]; return pom; } 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++) 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]; sum += v[i][j]; } }

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