# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
250991 |
2020-07-19T19:13:16 Z |
A02 |
Wombats (IOI13_wombats) |
C++14 |
|
20000 ms |
9312 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) {
fill_escape_costs();
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 |
Correct |
195 ms |
4944 KB |
Output is correct |
2 |
Correct |
212 ms |
4944 KB |
Output is correct |
3 |
Execution timed out |
20082 ms |
5412 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1181 ms |
504 KB |
Output is correct |
5 |
Correct |
502 ms |
504 KB |
Output is correct |
6 |
Correct |
851 ms |
504 KB |
Output is correct |
7 |
Correct |
709 ms |
504 KB |
Output is correct |
8 |
Correct |
619 ms |
512 KB |
Output is correct |
9 |
Correct |
764 ms |
424 KB |
Output is correct |
10 |
Correct |
669 ms |
504 KB |
Output is correct |
11 |
Execution timed out |
20086 ms |
708 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20051 ms |
880 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2572 ms |
9268 KB |
Output is correct |
2 |
Correct |
3981 ms |
9120 KB |
Output is correct |
3 |
Correct |
2541 ms |
9136 KB |
Output is correct |
4 |
Execution timed out |
20068 ms |
9312 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20073 ms |
888 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20081 ms |
888 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |