Submission #289019

# Submission time Handle Problem Language Result Execution time Memory
289019 2020-09-02T09:34:58 Z egekabas Wombats (IOI13_wombats) C++14
12 / 100
20000 ms 23808 KB
#include "wombats.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int r, c;
int sq = 100;
int h[5000][200];
int v[5000][200];
int dis[200][5000][200];
void dijkstra(int beg, int end, int imp, int dis[5000][200]){
    for(int i = beg; i <= end; ++i)
        for(int j = 0; j < c; ++j)
            dis[i][j] = 1e9+7;
    priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> pq;
    dis[end][imp] = 0;
    pq.push({0, {end, imp}});

    while(pq.size()){
        int d = pq.top().ff;
        int x = pq.top().ss.ff;
        int y = pq.top().ss.ss;
        pq.pop();
        if(d > dis[x][y])
            continue;
        if(x > beg && dis[x-1][y] > d + v[x-1][y]){
            dis[x-1][y] = d + v[x-1][y];
            pq.push({dis[x-1][y], {x-1, y}});
        }
        if(y > 0 && dis[x][y-1] > d + h[x][y-1]){
            dis[x][y-1] = d + h[x][y-1];
            pq.push({dis[x][y-1], {x, y-1}});
        }
        if(y < c-1 && dis[x][y+1] > d + h[x][y]){
            dis[x][y+1] = d + h[x][y];
            pq.push({dis[x][y+1], {x, y+1}});
        }
    }
}

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){
            h[i][j] = H[i][j];
            v[i][j] = V[i][j];
        }
    for(int i = 0; i < r; i += sq)
        for(int j = 0; j < c; ++j)
            dijkstra(i, min(i+sq, r-1), j, dis[j]);
}

void changeH(int P, int Q, int W) {
    h[P][Q] = W;
    int gr = P/sq;
    for(int j = 0; j < c; ++j)
        dijkstra(gr*sq, min(r-1, (gr+1)*sq), j, dis[j]);
    if(P%sq == 0 && gr > 0){
        --gr;
        for(int j = 0; j < c; ++j)
            dijkstra(gr*sq, min(r-1, (gr+1)*sq), j, dis[j]);
    }
}

void changeV(int P, int Q, int W) {
    v[P][Q] = W;
    int gr = P/sq;
    for(int j = 0; j < c; ++j)
        dijkstra(gr*sq, min(r-1, (gr+1)*sq), j, dis[j]);
}

int escape(int V1, int V2) {
    vector<int> curd(c, 1e9+7);
    vector<int> newd(c, 1e9+7);
    curd[V1] = 0;
    for(int i = 0; i < r; i += sq){
        for(int j = 0; j < c; ++j)
            for(int k = 0; k < c; ++k)
                newd[k] = min(newd[k], curd[j]+dis[k][i][j]);
        for(int j = 0; j < c; ++j){
            curd[j] = newd[j];
            newd[j] = 1e9+7;
        }
    }
    return curd[V2];
}

Compilation message

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 time Memory Grader output
1 Correct 12 ms 16000 KB Output is correct
2 Incorrect 12 ms 16000 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 2 ms 896 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
6 Correct 2 ms 896 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 195 ms 1912 KB Output is correct
12 Correct 3 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14747 ms 9204 KB Output is correct
2 Execution timed out 20099 ms 9264 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 23808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14718 ms 9080 KB Output is correct
2 Execution timed out 20080 ms 9380 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14971 ms 9080 KB Output is correct
2 Execution timed out 20099 ms 9260 KB Time limit exceeded
3 Halted 0 ms 0 KB -