Submission #1067823

#TimeUsernameProblemLanguageResultExecution timeMemory
106782312345678Wombats (IOI13_wombats)C++17
37 / 100
20082 ms24836 KiB
#include "wombats.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=5e3+5, cx=2e2+5;

int r, c, ver[nx][cx], horr[nx][cx], horl[nx][cx], dp[nx][cx];

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    r=R, c=C;
    for (int i=0; i<R-1; i++) for (int j=0; j<C; j++) ver[i][j]=V[i][j];
    for (int i=0; i<R; i++) for (int j=0; j<C-1; j++) horr[i][j]=H[i][j], horl[i][j+1]=H[i][j];
}

void changeH(int P, int Q, int W) {
    horr[P][Q]=W;
    horl[P][Q+1]=W;
}

void changeV(int P, int Q, int W) {
    ver[P][Q]=W;
}

int escape(int V1, int V2) {
    for (int i=0; i<r; i++) for (int j=0; j<c; j++) dp[i][j]=1e9;
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> pq;
    pq.push({0, 0, V1});
    dp[0][V1]=0;
    while (!pq.empty())
    {
        auto [w, cr, cc]=pq.top();
        pq.pop();
        if (cr!=r-1&&dp[cr+1][cc]>w+ver[cr][cc]) dp[cr+1][cc]=w+ver[cr][cc], pq.push({dp[cr+1][cc], cr+1, cc});
        if (cc!=c-1&&dp[cr][cc+1]>w+horr[cr][cc]) dp[cr][cc+1]=w+horr[cr][cc], pq.push({dp[cr][cc+1], cr, cc+1});
        if (cc!=0&&dp[cr][cc-1]>w+horl[cr][cc]) dp[cr][cc-1]=w+horl[cr][cc], pq.push({dp[cr][cc-1], cr, cc-1});
    }
    return dp[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...