답안 #289046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289046 2020-09-02T10:01:44 Z egekabas 웜뱃 (IOI13_wombats) C++14
55 / 100
5436 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<int, int> pii;
typedef pair<ld, ld> pld;
int r, c;
const int sq = 200;
int h[5000][200];
int v[5000][200];
int dis[5000/sq+5][200][sq+5][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-beg][j] = 1e9+7;
    dis[end-beg][imp] = 0;
    for(int i = end; i >= beg; --i){
        for(int j = 1; j < c; ++j)
            dis[i-beg][j] = min(dis[i-beg][j], dis[i-beg][j-1]+h[i][j-1]);
        for(int j = c-2; j >= 0; --j)
            dis[i-beg][j] = min(dis[i-beg][j], dis[i-beg][j+1]+h[i][j]);
        for(int 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(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[i/sq][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[gr][j]);
    if(gr > 0 && P%sq == 0){
        --gr;
        for(int 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;
    int gr = P/sq;
    for(int 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<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[i/sq][k][0][j]);
        for(int 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 11 ms 16128 KB Output is correct
2 Correct 11 ms 16128 KB Output is correct
3 Correct 143 ms 17784 KB Output is correct
4 Correct 12 ms 16128 KB Output is correct
5 Correct 13 ms 16128 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 209 ms 1912 KB Output is correct
12 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1091 ms 8824 KB Output is correct
2 Correct 1051 ms 8780 KB Output is correct
3 Correct 1085 ms 8952 KB Output is correct
4 Correct 1085 ms 9080 KB Output is correct
5 Correct 1076 ms 8824 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 5436 ms 8904 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 24064 KB Output is correct
2 Correct 22 ms 24064 KB Output is correct
3 Correct 20 ms 24064 KB Output is correct
4 Correct 107 ms 24952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1107 ms 8828 KB Output is correct
2 Correct 1089 ms 8824 KB Output is correct
3 Correct 1090 ms 8952 KB Output is correct
4 Correct 1111 ms 8824 KB Output is correct
5 Correct 1061 ms 8704 KB Output is correct
6 Correct 19 ms 24136 KB Output is correct
7 Correct 19 ms 24064 KB Output is correct
8 Correct 20 ms 24064 KB Output is correct
9 Correct 102 ms 24944 KB Output is correct
10 Correct 11 ms 16128 KB Output is correct
11 Correct 11 ms 16128 KB Output is correct
12 Correct 147 ms 17784 KB Output is correct
13 Correct 12 ms 16128 KB Output is correct
14 Correct 11 ms 16128 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 2 ms 768 KB Output is correct
19 Correct 1 ms 768 KB Output is correct
20 Correct 1 ms 768 KB Output is correct
21 Correct 2 ms 768 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 1 ms 768 KB Output is correct
24 Correct 2 ms 768 KB Output is correct
25 Correct 289 ms 1784 KB Output is correct
26 Correct 1 ms 768 KB Output is correct
27 Correct 5370 ms 8908 KB Output is correct
28 Runtime error 569 ms 262148 KB Execution killed with signal 9
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1073 ms 8824 KB Output is correct
2 Correct 1050 ms 8824 KB Output is correct
3 Correct 1079 ms 8952 KB Output is correct
4 Correct 1083 ms 8952 KB Output is correct
5 Correct 1084 ms 8824 KB Output is correct
6 Correct 19 ms 24064 KB Output is correct
7 Correct 20 ms 24064 KB Output is correct
8 Correct 20 ms 24064 KB Output is correct
9 Correct 97 ms 24948 KB Output is correct
10 Correct 11 ms 16128 KB Output is correct
11 Correct 12 ms 16128 KB Output is correct
12 Correct 143 ms 17788 KB Output is correct
13 Correct 11 ms 16128 KB Output is correct
14 Correct 11 ms 16128 KB Output is correct
15 Runtime error 1016 ms 262148 KB Execution killed with signal 9
16 Halted 0 ms 0 KB -