Submission #358277

#TimeUsernameProblemLanguageResultExecution timeMemory
358277beksultan04Wombats (IOI13_wombats)C++14
28 / 100
20102 ms20512 KiB
#include "wombats.h"
#ifndef EVAL
#include "grader.c"
#endif // EVAL
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define INF 1e9+7

int r[5000][200],d[5000][200],cost[5000][200],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;++j){
            cost[i][j] = INF;
            r[i][j] = H[i][j];
            d[i][j] = V[i][j];
        }
    /* ... */
}

void changeH(int P, int Q, int W) {
    r[P][Q] = W;
    /* ... */
}

void changeV(int P, int Q, int W) {
    d[P][Q] = W;
    /* ... */
}

int escape(int V1, int V2) {

    for (int i=0;i<R;++i)
        for (int j=0;j<C;++j)
            cost[i][j] = INF;


    priority_queue <pair<int,pii> > s;
    s.push({0,{0,V1}});
    cost[0][V1] = 0;
    while (!s.empty()){
        pii p = s.top().sc;
        s.pop();
        if (p.fr+1 < R){
            if (cost[p.fr+1][p.sc] > cost[p.fr][p.sc]+d[p.fr][p.sc]){

                cost[p.fr+1][p.sc] = cost[p.fr][p.sc]+d[p.fr][p.sc];
                s.push({-cost[p.fr+1][p.sc],{p.fr+1,p.sc}});

            }
        }
        if (p.sc+1 < C){
            if (cost[p.fr][p.sc+1] > cost[p.fr][p.sc]+r[p.fr][p.sc]){

                cost[p.fr][p.sc+1] = cost[p.fr][p.sc]+r[p.fr][p.sc];
                s.push({-cost[p.fr][p.sc+1],{p.fr,p.sc+1}});

            }
        }
        if (p.sc-1 >= 0){
            if (cost[p.fr][p.sc-1] > cost[p.fr][p.sc]+r[p.fr][p.sc-1]){

                cost[p.fr][p.sc-1] = cost[p.fr][p.sc]+r[p.fr][p.sc-1];
                s.push({-cost[p.fr][p.sc-1],{p.fr,p.sc-1}});

            }
        }

    }


    return cost[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...