답안 #289050

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289050 2020-09-02T10:03:57 Z egekabas 웜뱃 (IOI13_wombats) C++14
55 / 100
5757 ms 262148 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<ll, ll> pii;
typedef pair<ld, ld> pld;
ll r, c;
const ll sq = 200;
ll h[5000][200];
ll v[5000][200];
ll dis[5000/sq+5][200][sq+5][200];
void dijkstra(ll beg, ll end, ll imp, ll dis[5000][200]){
    for(ll i = beg; i <= end; ++i)
        for(ll j = 0; j < c; ++j)
            dis[i-beg][j] = 1e9+7;
    dis[end-beg][imp] = 0;
    for(ll i = end; i >= beg; --i){
        for(ll j = 1; j < c; ++j)
            dis[i-beg][j] = min(dis[i-beg][j], dis[i-beg][j-1]+h[i][j-1]);
        for(ll j = c-2; j >= 0; --j)
            dis[i-beg][j] = min(dis[i-beg][j], dis[i-beg][j+1]+h[i][j]);
        for(ll j = 0; j < c && i != beg; ++j)
            dis[i-1-beg][j] = min(dis[i-1-beg][j] ,dis[i-beg][j] + v[i-1][j]);
    }
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    r = R;
    c = C;
    for(ll i = 0; i < r; ++i)
        for(ll j = 0; j < c; ++j){
            h[i][j] = H[i][j];
            v[i][j] = V[i][j];
        }
    for(ll i = 0; i < r; i += sq)
        for(ll j = 0; j < c; ++j)
            dijkstra(i, min(i+sq, r-1), j, dis[i/sq][j]);
}

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

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

int escape(int V1, int V2) {
    vector<ll> curd(c, 1e9+7);
    vector<ll> newd(c, 1e9+7);
    curd[V1] = 0;
    for(ll i = 0; i < r; i += sq){
        for(ll j = 0; j < c; ++j)
            for(ll k = 0; k < c; ++k)
                newd[k] = min(newd[k], curd[j]+dis[i/sq][k][0][j]);
        for(ll j = 0; j < c; ++j){
            curd[j] = newd[j];
            newd[j] = 1e9+7;
        }
    }
    assert(curd[V2] >= 0);
    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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 27904 KB Output is correct
2 Correct 17 ms 27904 KB Output is correct
3 Correct 154 ms 29560 KB Output is correct
4 Correct 18 ms 27904 KB Output is correct
5 Correct 17 ms 27904 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 2 ms 1152 KB Output is correct
5 Correct 2 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1024 KB Output is correct
9 Correct 1 ms 1152 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
11 Correct 212 ms 2140 KB Output is correct
12 Correct 2 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1161 ms 16828 KB Output is correct
2 Correct 1156 ms 16632 KB Output is correct
3 Correct 1165 ms 16888 KB Output is correct
4 Correct 1172 ms 16888 KB Output is correct
5 Correct 1163 ms 16760 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 5726 ms 16880 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 39808 KB Output is correct
2 Correct 30 ms 39800 KB Output is correct
3 Correct 28 ms 39808 KB Output is correct
4 Correct 108 ms 40568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1172 ms 16632 KB Output is correct
2 Correct 1151 ms 16636 KB Output is correct
3 Correct 1190 ms 16888 KB Output is correct
4 Correct 1173 ms 16888 KB Output is correct
5 Correct 1152 ms 16760 KB Output is correct
6 Correct 28 ms 39808 KB Output is correct
7 Correct 28 ms 39808 KB Output is correct
8 Correct 28 ms 39808 KB Output is correct
9 Correct 110 ms 40568 KB Output is correct
10 Correct 17 ms 27904 KB Output is correct
11 Correct 17 ms 27904 KB Output is correct
12 Correct 149 ms 29560 KB Output is correct
13 Correct 18 ms 27904 KB Output is correct
14 Correct 17 ms 27904 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 ms 1152 KB Output is correct
19 Correct 1 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
21 Correct 1 ms 1152 KB Output is correct
22 Correct 1 ms 1024 KB Output is correct
23 Correct 1 ms 1152 KB Output is correct
24 Correct 1 ms 1152 KB Output is correct
25 Correct 215 ms 2200 KB Output is correct
26 Correct 2 ms 1152 KB Output is correct
27 Correct 5757 ms 16876 KB Output is correct
28 Runtime error 405 ms 262148 KB Execution killed with signal 9
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1163 ms 16836 KB Output is correct
2 Correct 1164 ms 16764 KB Output is correct
3 Correct 1169 ms 16872 KB Output is correct
4 Correct 1165 ms 16888 KB Output is correct
5 Correct 1162 ms 16768 KB Output is correct
6 Correct 27 ms 39808 KB Output is correct
7 Correct 27 ms 39808 KB Output is correct
8 Correct 30 ms 39800 KB Output is correct
9 Correct 106 ms 40568 KB Output is correct
10 Correct 17 ms 27904 KB Output is correct
11 Correct 17 ms 27904 KB Output is correct
12 Correct 147 ms 29560 KB Output is correct
13 Correct 18 ms 27904 KB Output is correct
14 Correct 17 ms 27904 KB Output is correct
15 Runtime error 703 ms 262148 KB Execution killed with signal 9
16 Halted 0 ms 0 KB -