답안 #250990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250990 2020-07-19T19:11:33 Z A02 웜뱃 (IOI13_wombats) C++14
39 / 100
20000 ms 10640 KB
#include "wombats.h"
#include <vector>
#include <set>
#include <algorithm>
#include <utility>
#include <queue>
#include <iostream>

using namespace std;

int R;
int C;
vector<vector<long long> > Hwombats;
vector<vector<long long> > Vwombats;
vector<vector<long long> > escapeCostV2V1;

void fill_escape_costs(){

    for (int v1 = 0; v1 < C; v1++){

        priority_queue<pair<long long, pair<int, int> > > to_visit;

        vector<vector<long long> > costs (R, vector<long long> (C,(R + C) * 2000));

        to_visit.push(make_pair(0, make_pair(0, v1)));

        while (!to_visit.empty()){

            pair<long long, pair<int, int> > current = to_visit.top();
            to_visit.pop();
            long long d = -current.first;
            int r = current.second.first;
            int c = current.second.second;
            if (costs[r][c] == (R + C) * 2000){

                costs[r][c] = d;

                if (c != 0){
                    int nr = r;
                    int nc = c - 1;
                    long long nd = d + Hwombats[r][c - 1];
                    to_visit.push(make_pair(-nd, make_pair(nr, nc)));
                }
                if (c != C - 1){
                    int nr = r;
                    int nc = c + 1;
                    long long nd = d + Hwombats[r][c];
                    to_visit.push(make_pair(-nd, make_pair(nr, nc)));
                }
                if (r != R - 1){
                    int nr = r + 1;
                    int nc = c;
                    long long nd = d + Vwombats[r][c];
                    to_visit.push(make_pair(-nd, make_pair(nr, nc)));
                }
            }

        }

        for (int v2 = 0; v2 < C; v2++){
            escapeCostV2V1[v2][v1] = costs[R - 1][v2];
            //cout << v1 << ' ' << v2 << ' ' << costs[R - 1][v2] << endl;
        }

    }

}

void init(int r, int c, int H[5000][200], int V[5000][200]) {
    R = r;
    C = c;
    Hwombats = vector<vector<long long> > (R, vector<long long> (C - 1, 0));
    Vwombats = vector<vector<long long> > (R - 1, vector<long long> (C, 0));

    for (int i = 0; i < R; i++){
        for (int j = 0; j < C - 1; j++){
            Hwombats[i][j] = H[i][j];
        }
    }

    for (int i = 0; i < R - 1; i++){
        for (int j = 0; j < C; j++){
            Vwombats[i][j] = V[i][j];
        }
    }

    escapeCostV2V1 = vector<vector<long long> > (C, vector<long long> (C, 0));
    fill_escape_costs();
}

void changeH(int P, int Q, int W) {
    Hwombats[P][Q] = W;
    fill_escape_costs();
}

void changeV(int P, int Q, int W) {
    Vwombats[P][Q] = W;
    fill_escape_costs();
}

int escape(int V1, int V2) {
    return escapeCostV2V1[V2][V1];
}

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 200 ms 4968 KB Output is correct
2 Correct 189 ms 5040 KB Output is correct
3 Correct 279 ms 7592 KB Output is correct
4 Correct 190 ms 5032 KB Output is correct
5 Correct 197 ms 5060 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 96 ms 2808 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20090 ms 888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1250 ms 9128 KB Output is correct
2 Correct 2017 ms 9328 KB Output is correct
3 Correct 1284 ms 9284 KB Output is correct
4 Correct 1290 ms 10640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20096 ms 880 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20091 ms 888 KB Time limit exceeded
2 Halted 0 ms 0 KB -