Submission #1216474

#TimeUsernameProblemLanguageResultExecution timeMemory
1216474kiennguyendinhCrocodile's Underground City (IOI11_crocodile)C++17
0 / 100
1 ms2624 KiB
#include <bits/stdc++.h> #include "crocodile.h" using namespace std; int n,m,x,y; long long w,inf = 1e18; vector<pair<int,long long>> adj[100001]; long long dist[100001][2]; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); for(int i = 0; i < M; i++) { x = R[i][0],y = R[i][1],w = L[i]; adj[x].push_back({y,w}); adj[y].push_back({x,w}); } for(int i = 0;i < N;i++) dist[i][0] = dist[i][1] = inf; queue<pair<long long,int>> q; for(int i = 0;i < K;i++) { dist[P[i]][0] = dist[P[i]][1] = 0; q.push({P[i],0}); } while(!q.empty()) { int u = q.front().first; long long val = q.front().second; q.pop(); for(pair<int,long long> v : adj[u]) { if(dist[v.first][1] > val + v.second) { dist[v.first][1] = val + v.second; if(dist[v.first][0] > dist[v.first][1]) swap(dist[v.first][0], dist[v.first][1]); q.push({dist[v.first][1],v.first}); } } } return dist[0][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...