# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
250985 |
2020-07-19T18:41:36 Z |
A02 |
Wombats (IOI13_wombats) |
C++14 |
|
20000 ms |
9308 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<int> > Hwombats;
vector<vector<int> > Vwombats;
vector<vector<int> > escapeCostV2V1;
void fill_escape_costs(){
for (int v2 = 0; v2 < C; v2++){
priority_queue<pair<int, pair<int, int> > > to_visit;
vector<vector<int> > costs (R, vector<int> (C,(R + C) * 2000));
to_visit.push(make_pair(0, make_pair(R - 1, v2)));
while (!to_visit.empty()){
pair<int, pair<int, int> > current = to_visit.top();
to_visit.pop();
int 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;
int 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;
int nd = d + Hwombats[r][c];
to_visit.push(make_pair(-nd, make_pair(nr, nc)));
}
if (r != 0){
int nr = r - 1;
int nc = c;
int nd = d + Vwombats[r - 1][c];
to_visit.push(make_pair(-nd, make_pair(nr, nc)));
}
}
}
for (int v1 = 0; v1 < C; v1++){
escapeCostV2V1[v2][v1] = costs[0][v1];
}
}
}
void init(int r, int c, int H[5000][200], int V[5000][200]) {
R = r;
C = c;
Hwombats = vector<vector<int> > (R, vector<int> (C - 1, 0));
Vwombats = vector<vector<int> > (R - 1, vector<int> (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<int> > (C, vector<int> (C, 0));
fill_escape_costs();
cout << 'a' << endl;
}
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;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
203 ms |
4944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20099 ms |
760 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1328 ms |
9308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20076 ms |
640 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20037 ms |
724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |