# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
289013 |
2020-09-02T09:32:07 Z |
egekabas |
Wombats (IOI13_wombats) |
C++14 |
|
20000 ms |
23936 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;
int sq = 100;
int h[5000][200];
int v[5000][200];
int dis[200][5000][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][j] = 1e9+7;
priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> pq;
dis[end][imp] = 0;
pq.push({0, {end, imp}});
while(pq.size()){
int d = pq.top().ff;
int x = pq.top().ss.ff;
int y = pq.top().ss.ss;
pq.pop();
if(d > dis[x][y])
continue;
if(x > beg && dis[x-1][y] > d + v[x-1][y]){
dis[x-1][y] = d + v[x-1][y];
pq.push({dis[x-1][y], {x-1, y}});
}
if(y > 0 && dis[x][y-1] > d + h[x][y-1]){
dis[x][y-1] = d + h[x][y-1];
pq.push({dis[x][y-1], {x, y-1}});
}
if(y < c-1 && dis[x][y+1] > d + h[x][y]){
dis[x][y+1] = d + h[x][y];
pq.push({dis[x][y+1], {x, y+1}});
}
}
}
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[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[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[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[k][i][j]);
for(int j = 0; j < c; ++j){
curd[j] = newd[j];
newd[j] = 1e9+7;
}
}
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;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
16000 KB |
Output is correct |
2 |
Incorrect |
12 ms |
16000 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
896 KB |
Output is correct |
5 |
Correct |
2 ms |
896 KB |
Output is correct |
6 |
Correct |
2 ms |
896 KB |
Output is correct |
7 |
Correct |
3 ms |
896 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
896 KB |
Output is correct |
10 |
Correct |
2 ms |
896 KB |
Output is correct |
11 |
Correct |
229 ms |
3320 KB |
Output is correct |
12 |
Correct |
3 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15150 ms |
9276 KB |
Output is correct |
2 |
Execution timed out |
20081 ms |
9768 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
23936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14999 ms |
9328 KB |
Output is correct |
2 |
Execution timed out |
20067 ms |
9692 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14865 ms |
9276 KB |
Output is correct |
2 |
Execution timed out |
20097 ms |
9408 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |