Submission #995559

#TimeUsernameProblemLanguageResultExecution timeMemory
995559NurislamCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
388 ms71192 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() //#define int long long #define Mp make_pair //#define double double long typedef vector<int> vi; typedef vector<double> vd; typedef pair<int,int> pii; typedef vector<pii> vii; const int maxN = 1e6, inf = 1e9, mod = 1e9+7; #include "crocodile.h" //#include "grader.cpp" int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) { vii g[n]; for(int i = 0; i < m; i++){ g[r[i][0]].pb({l[i], r[i][1]}); g[r[i][1]].pb({l[i], r[i][0]}); } for(int i = 0; i < n; i++)sort(all(g[i])); priority_queue<pii, vii, greater<pii>> q; int us[n]{}; for(int i = 0; i < k; i++){ us[p[i]] = 1; q.push({0, p[i]}); } while(!q.empty()){ auto [dis, x] = q.top(); q.pop(); us[x]++; //cout << x << '\n'; if(us[x] == 2){ if(x == 0)return dis; for(auto [ct, to]:g[x]){ if(us[to] == 2)continue; q.push({dis+ct, to}); } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...