#include "wombats.h"
#include <bits/stdc++.h>
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define all(x) x.begin() , x.end()
typedef long long ll;
using namespace std;
const int N = 6e3+5;
const long long oo = 1e18;
ll dx[] = {1 , -1 , 0} ;
ll dy[] = {0 , 0 , 1} ;
ll n , m , h[N][204] , v[N][204] , sum , c , r ;
ll dis[105][105] ;
set < pair <ll, pair <ll, ll>> > st ;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
n = R , m = C ;
for (int i = 0 ; i<n ; i++)
{
for (int j = 0 ; j<m ; j++)
{
v[i][j] = V[i][j] , h[i][j] = H[i][j] ;
sum += v[i][j] ;
}
}
}
void changeH(int P, int Q, int W) {
h[P][Q] = W ;
}
void changeV(int P, int Q, int W) {
sum -= v[P][Q] ;
sum += W ;
v[P][Q] = W ;
}
int escape(int V1, int V2)
{
if (m == 1)
return sum ;
for (int p = 0 ; p<n ; p++)
for (int j = 0 ; j<m ; j++)
dis[p][j] = oo ;
st.insert({0 , {0 , V1}});
while (!st.empty())
{
pair <ll , pair <ll,ll>> pr = *st.begin() ;
st.erase(st.begin());
ll cos = pr.F , x = pr.S.F , y = pr.S.S ;
if (cos + v[x][y] < dis[x+1][y] && x+1 < n)
{
dis[x+1][y] = cos + v[x][y] ;
st.insert({dis[x+1][y] , {x+1 , y}});
}
if (cos + h[x][y] < dis[x][y+1] && y+1<m)
{
dis[x][y+1] = cos + h[x][y] ;
st.insert({dis[x][y+1] , {x , y+1}});
}
if (cos + h[x][y-1] < dis[x][y-1] && y-1 >= 0)
{
dis[x][y-1] = cos + h[x][y-1] ;
st.insert({dis[x][y-1] , {x , y-1}});
}
}
return dis[n-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]
15 | int res;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
20180 KB |
Output is correct |
2 |
Correct |
10 ms |
20168 KB |
Output is correct |
3 |
Correct |
75 ms |
22072 KB |
Output is correct |
4 |
Correct |
10 ms |
20180 KB |
Output is correct |
5 |
Correct |
11 ms |
20168 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
22 ms |
340 KB |
Output is correct |
5 |
Correct |
13 ms |
436 KB |
Output is correct |
6 |
Correct |
14 ms |
440 KB |
Output is correct |
7 |
Correct |
21 ms |
340 KB |
Output is correct |
8 |
Correct |
22 ms |
340 KB |
Output is correct |
9 |
Correct |
25 ms |
444 KB |
Output is correct |
10 |
Correct |
23 ms |
340 KB |
Output is correct |
11 |
Correct |
11731 ms |
1856 KB |
Output is correct |
12 |
Correct |
34 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
852 KB |
Output is correct |
2 |
Correct |
225 ms |
1264 KB |
Output is correct |
3 |
Correct |
194 ms |
1016 KB |
Output is correct |
4 |
Correct |
192 ms |
888 KB |
Output is correct |
5 |
Correct |
194 ms |
884 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
198 ms |
964 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
24096 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
194 ms |
884 KB |
Output is correct |
2 |
Correct |
213 ms |
1200 KB |
Output is correct |
3 |
Correct |
196 ms |
896 KB |
Output is correct |
4 |
Correct |
197 ms |
972 KB |
Output is correct |
5 |
Correct |
212 ms |
888 KB |
Output is correct |
6 |
Incorrect |
22 ms |
24148 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
852 KB |
Output is correct |
2 |
Correct |
219 ms |
1268 KB |
Output is correct |
3 |
Correct |
195 ms |
892 KB |
Output is correct |
4 |
Correct |
196 ms |
852 KB |
Output is correct |
5 |
Correct |
198 ms |
972 KB |
Output is correct |
6 |
Incorrect |
24 ms |
24112 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |