Submission #1192409

#TimeUsernameProblemLanguageResultExecution timeMemory
1192409julia_08Crocodile's Underground City (IOI11_crocodile)C++20
0 / 100
1 ms2628 KiB
#include <bits/stdc++.h> #include "crocodile.h" using namespace std; using ll = long long; const int MAXN = 1e5 + 10; int chamber[MAXN]; int marc[MAXN], deg[MAXN]; ll dist[MAXN][2]; vector<pair<int, int>> adj[MAXN]; int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){ for(int i=0; i<n; i++) dist[i][0] = dist[i][1] = 1e18; for(int i=0; i<k; i++) chamber[p[i]] = 1; for(int i=0; i<m; i++){ adj[r[i][0]].push_back({r[i][1], l[i]}); adj[r[i][1]].push_back({r[i][0], l[i]}); } queue<int> q; for(int i=0; i<n; i++){ if(chamber[i]){ q.push(i); marc[i] = 1; dist[i][0] = dist[i][1] = 0; } } while(!q.empty()){ int v = q.front(); q.pop(); for(auto [u, w] : adj[v]){ deg[u] ++; if(dist[v][1] + w <= dist[u][0]){ dist[u][1] = dist[u][0]; dist[u][0] = dist[v][1] + w; } else if(dist[v][1] + w < dist[u][1]) dist[u][1] = dist[v][1] + w; if(deg[u] >= 2){ if(!marc[u]){ q.push(u); marc[u] = 1; } } } } return dist[0][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...