//#pragma once
#include "wombats.h"
#include <bits/stdc++.h>
#define f first
#define s second
const int INF = 1e9 + 7;
using namespace std;
const int B = 200000 + 10;
int n,m;
vector <pair <int,int> > reb[B];
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 - 1;j++) {
reb[i*m + j].push_back({i*m + j + 1,H[i][j]});
reb[i*m + j + 1].push_back({i*m + j,H[i][j]});
}
}
for(int i = 0;i < n - 1;i++) {
for(int j = 0;j < m;j++) {
reb[i*m + j].push_back({(i + 1)*m + j,V[i][j]});
}
}
};
void changeH(int P, int Q, int W) {
};
void changeV(int P, int Q, int W) {
};
int dijkstra(int x,int y) {
int rast[n*m] = {};
for(int i = 0;i < n*m;i++) {
rast[i] = INF;
}
rast[x] = 0;
set <pair <int,int> > s;
s.insert({0,x});
while(!s.empty()) {
pair <int,int> v = *s.begin();
s.erase(s.find(v));
for(auto u:reb[v.s]) {
int rst = u.s + v.f;
if(rst < rast[u.f]) {
s.erase({rast[u.f],u.f});
rast[u.f] = rst;
s.insert({rast[u.f],u.f});
}
}
}
return rast[m*(n - 1) + y];
}
int escape(int V1, int V2) {
int x = V1,y = V2;
return dijkstra(x,y);
};
/*
signed main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 0;i < n;i++) {
for(int j = 0;j < m - 1;j++) {
cin >> H[i][j];
}
}
for(int i = 0;i < n - 1;i++) {
for(int j = 0;j < m;j++) {
cin >> V[i][j];
}
}
init(n,m);
int q;
cin >> q;
while(q--) {
int type;
cin >> type;
if(type == 3) {
int x,y;
cin >> x >> y;
cout << escape(x,y) << endl;
}
else {
int a,b,c;
cin >> a >> b >> c;
}
}
}
*/
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;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
93 ms |
10844 KB |
Output is correct |
2 |
Incorrect |
95 ms |
11056 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
24 ms |
8792 KB |
Output is correct |
5 |
Correct |
12 ms |
8540 KB |
Output is correct |
6 |
Correct |
13 ms |
8724 KB |
Output is correct |
7 |
Correct |
21 ms |
8728 KB |
Output is correct |
8 |
Correct |
24 ms |
8728 KB |
Output is correct |
9 |
Correct |
28 ms |
8792 KB |
Output is correct |
10 |
Correct |
29 ms |
8708 KB |
Output is correct |
11 |
Correct |
12464 ms |
9660 KB |
Output is correct |
12 |
Correct |
28 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
217 ms |
9300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
563 ms |
13292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
208 ms |
9256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
207 ms |
9252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |