답안 #108575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
108575 2019-04-30T09:11:42 Z tictaccat 웜뱃 (IOI13_wombats) C++14
55 / 100
20000 ms 30596 KB
#include "wombats.h"
#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9;

int sum, R, C;
vector<vector<int>> H(5050,vector<int>(210,INF)), V(5050,vector<int>(210,INF)); 
vector<vector<int>> ans(210,vector<int>(210,-1));

void init(int Rt, int Ct, int tH[5000][200], int tV[5000][200]) {
    /* ... */
    R = Rt; C = Ct;
    for (int i = 0; i < 5000; i++) for (int j = 0; j < 200; j++) {H[i][j] = tH[i][j]; V[i][j] = tV[i][j];}
}

void changeH(int P, int Q, int W) {
    /* ... */
    H[P][Q] = W;
    ans.clear();
    ans.assign(210,vector<int>(210,-1));
}

void changeV(int P, int Q, int W) {
    /* ... */
    V[P][Q] = W;
    ans.clear();
    ans.assign(210,vector<int>(210,-1));
}

int escape(int V1, int V2) {
   // assert(V1 == 0 && V2 == 0);

    if (ans[V1][V2] != -1) {
        //cout << "test\n";
        return ans[V1][V2];
    }

    priority_queue<tuple<int,int,int>> pq;
    vector<vector<int>> dist(R,vector<int>(C,-1));

    pq.push(make_tuple(0,V1,0));

    while (!pq.empty()) {
        int c,r,d; tie(d,c,r) = pq.top(); pq.pop();
        if (dist[r][c] != -1) continue;
        d *= -1;
        dist[r][c] = d;
        if (c > 0 && (dist[r][c-1] == -1 || dist[r][c-1] > d + H[r][c-1])) pq.push(make_tuple(-(d + H[r][c-1]),c-1,r));
        if (c < C-1 && (dist[r][c+1] == -1 || dist[r][c+1] > d + H[r][c])) pq.push(make_tuple(-(d + H[r][c]),c+1,r));
        if (r < R-1 && (dist[r+1][c] == -1 || dist[r+1][c] > d + V[r][c])) pq.push(make_tuple(-(d + V[r][c]),c,r+1));
    }

    return (ans[V1][V2] = dist[R-1][V2]);
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 296 ms 13644 KB Output is correct
2 Correct 240 ms 13448 KB Output is correct
3 Correct 270 ms 14776 KB Output is correct
4 Correct 319 ms 13476 KB Output is correct
5 Correct 224 ms 13428 KB Output is correct
6 Correct 26 ms 9216 KB Output is correct
7 Correct 14 ms 9216 KB Output is correct
8 Correct 16 ms 9344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 9088 KB Output is correct
2 Correct 16 ms 9216 KB Output is correct
3 Correct 16 ms 9216 KB Output is correct
4 Correct 51 ms 9216 KB Output is correct
5 Correct 37 ms 9216 KB Output is correct
6 Correct 38 ms 9216 KB Output is correct
7 Correct 48 ms 9216 KB Output is correct
8 Correct 41 ms 9216 KB Output is correct
9 Correct 44 ms 9216 KB Output is correct
10 Correct 46 ms 9216 KB Output is correct
11 Correct 137 ms 10124 KB Output is correct
12 Correct 44 ms 9308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 248 ms 9384 KB Output is correct
2 Correct 337 ms 9708 KB Output is correct
3 Correct 245 ms 9444 KB Output is correct
4 Correct 214 ms 9464 KB Output is correct
5 Correct 232 ms 9464 KB Output is correct
6 Correct 15 ms 9216 KB Output is correct
7 Correct 15 ms 9216 KB Output is correct
8 Correct 17 ms 9216 KB Output is correct
9 Correct 240 ms 9464 KB Output is correct
10 Correct 15 ms 9216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 916 ms 17432 KB Output is correct
2 Correct 2223 ms 17600 KB Output is correct
3 Correct 1084 ms 17452 KB Output is correct
4 Correct 2348 ms 18608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 191 ms 9472 KB Output is correct
2 Correct 285 ms 9676 KB Output is correct
3 Correct 249 ms 9424 KB Output is correct
4 Correct 219 ms 9464 KB Output is correct
5 Correct 225 ms 9468 KB Output is correct
6 Correct 1428 ms 17576 KB Output is correct
7 Correct 1921 ms 17760 KB Output is correct
8 Correct 1034 ms 17520 KB Output is correct
9 Correct 2037 ms 18748 KB Output is correct
10 Correct 217 ms 13456 KB Output is correct
11 Correct 206 ms 13392 KB Output is correct
12 Correct 299 ms 15952 KB Output is correct
13 Correct 251 ms 13360 KB Output is correct
14 Correct 245 ms 13408 KB Output is correct
15 Correct 14 ms 9088 KB Output is correct
16 Correct 16 ms 9088 KB Output is correct
17 Correct 15 ms 9088 KB Output is correct
18 Correct 44 ms 9216 KB Output is correct
19 Correct 28 ms 9216 KB Output is correct
20 Correct 35 ms 9216 KB Output is correct
21 Correct 43 ms 9216 KB Output is correct
22 Correct 36 ms 9216 KB Output is correct
23 Correct 40 ms 9216 KB Output is correct
24 Correct 42 ms 9216 KB Output is correct
25 Correct 128 ms 11484 KB Output is correct
26 Correct 47 ms 9216 KB Output is correct
27 Correct 275 ms 9480 KB Output is correct
28 Execution timed out 20016 ms 23092 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 234 ms 9436 KB Output is correct
2 Correct 279 ms 9684 KB Output is correct
3 Correct 229 ms 9464 KB Output is correct
4 Correct 249 ms 9344 KB Output is correct
5 Correct 222 ms 9344 KB Output is correct
6 Correct 1223 ms 17544 KB Output is correct
7 Correct 2635 ms 17660 KB Output is correct
8 Correct 978 ms 17652 KB Output is correct
9 Correct 2551 ms 18572 KB Output is correct
10 Correct 302 ms 13376 KB Output is correct
11 Correct 238 ms 13372 KB Output is correct
12 Correct 294 ms 15908 KB Output is correct
13 Correct 229 ms 13428 KB Output is correct
14 Correct 257 ms 13864 KB Output is correct
15 Correct 1500 ms 30596 KB Output is correct
16 Execution timed out 20067 ms 29024 KB Time limit exceeded
17 Halted 0 ms 0 KB -