#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 inf = 1e18;
const int N = 1e5 + 5;
vector<int> adj[N];
bool vis[N];
i64 dist[N];
vector<int> b;
struct item{
i64 cost;
int wh;
item(i64 _cost = 0,int _wh = 0){
cost = _cost;
wh = _wh;
}
bool operator > (const item & i) const{
if(i.cost == cost){
return (i.wh == 0 ? 0 : b[i.wh - 1]) < (wh == 0 ? 0 : b[wh - 1]);
}
return i.cost < cost;
}
};
i64 solve(int N, int M, int W, std::vector<int> T,
vector<int> X, vector<int> Y,
vector<int> A, vector<int> B, vector<int> C,
vector<int> L, vector<int> R){
b = B;
assert(W == 0);
for(int i = 0;i < max(N,M);i++){
dist[i] = inf;
vis[i] = false;
adj[i].clear();
}
// vector<vector<int>> adj(N);
for(int i = 0;i < M;i++){
adj[X[i]].push_back(i);
}
// vector<i64> dist(M + 1,inf);
// vector<bool> vis(M + 1,false);
priority_queue<item,vector<item>,greater<item>> pq;
dist[0] = 0;
pq.push(item(0,0));
i64 ans = inf;
while(!pq.empty()){
auto top = pq.top();
pq.pop();
i64 cost = top.cost;
int wh = top.wh;
int u = (wh == 0 ? 0 : Y[wh - 1]);
int time = (wh == 0 ? 0 : B[wh - 1]);
if(vis[wh] || cost > dist[wh]) continue;
vis[wh] = true;
if(wh > 0 && Y[wh - 1] == N - 1) ans = min(ans,cost);
for(int v : adj[u]){
if(A[v] >= time && dist[v + 1] > cost + C[v]){
pq.push(item(cost + C[v],v + 1));
dist[v + 1] = C[v] + cost;
}
}
}
if(ans == inf) return -1;
else return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
6836 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
13264 KB |
Correct. |
2 |
Correct |
49 ms |
15700 KB |
Correct. |
3 |
Correct |
1 ms |
3416 KB |
Correct. |
4 |
Correct |
8 ms |
4780 KB |
Correct. |
5 |
Correct |
1 ms |
3420 KB |
Correct. |
6 |
Correct |
94 ms |
13300 KB |
Correct. |
7 |
Correct |
1 ms |
3416 KB |
Correct. |
8 |
Execution timed out |
1039 ms |
14704 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
13264 KB |
Correct. |
2 |
Correct |
49 ms |
15700 KB |
Correct. |
3 |
Correct |
1 ms |
3416 KB |
Correct. |
4 |
Correct |
8 ms |
4780 KB |
Correct. |
5 |
Correct |
1 ms |
3420 KB |
Correct. |
6 |
Correct |
94 ms |
13300 KB |
Correct. |
7 |
Correct |
1 ms |
3416 KB |
Correct. |
8 |
Execution timed out |
1039 ms |
14704 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
6836 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |