# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
583517 |
2022-06-25T13:27:46 Z |
AngusWong |
Robot (JOI21_ho_t4) |
C++17 |
|
501 ms |
35856 KB |
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define f first
#define s second
using namespace std;
ll n, m, x, y, c, p, dist[100001];
vector<pll> v[100001];
map<ll, ll> cnt[100001];
priority_queue<pair<pll, ll>, vector<pair<pll, ll> >, greater<pair<pll, ll> > > pq;
void dij(ll st){
for (int i=1; i<=n; i++) dist[i]=1e18;
dist[st]=0;
pq.push({{0, st}, 0});
while (!pq.empty()){
pll p=pq.top().f;
ll color=pq.top().s;
pq.pop();
if (dist[p.s]!=p.f) continue;
if (color) cnt[p.s][color]--;
for (pll i: v[p.s]){
if (cnt[p.s][i.s]==1){
if (dist[i.f]>p.f){
dist[i.f]=p.f;
pq.push({{p.f, i.f}, 0});
}
}else{
if (dist[i.f]>p.f+1){
dist[i.f]=p.f+1;
pq.push({{p.f+1, i.f}, i.s});
}
}
}
if (color) cnt[p.s][color]++;
}
}
int main(){
cin >> n >> m;
for (int i=1; i<=m; i++){
cin >> x >> y >> c >> p;
v[x].push_back({y, c});
v[y].push_back({x, c});
cnt[x][c]++, cnt[y][c]++;
}
dij(1);
if (dist[n]==1e18) cout << "-1\n";
else cout << dist[n] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7252 KB |
Output is correct |
2 |
Correct |
4 ms |
7252 KB |
Output is correct |
3 |
Incorrect |
4 ms |
7252 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
130 ms |
16220 KB |
Output is correct |
2 |
Correct |
52 ms |
11792 KB |
Output is correct |
3 |
Correct |
162 ms |
18012 KB |
Output is correct |
4 |
Correct |
106 ms |
13452 KB |
Output is correct |
5 |
Incorrect |
501 ms |
35856 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7252 KB |
Output is correct |
2 |
Correct |
4 ms |
7252 KB |
Output is correct |
3 |
Incorrect |
4 ms |
7252 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |