Submission #140353

#TimeUsernameProblemLanguageResultExecution timeMemory
140353muradeynCrocodile's Underground City (IOI11_crocodile)C++14
89 / 100
2041 ms51804 KiB
#include "crocodile.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; const int maxx = 100000; int x , y; int ext[maxx]; long long ans[maxx]; vector< pair<int,int> >v[maxx]; int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) { for (int i = 0;i<n;i++)ans[i] = INT_MAX; for (int i = 0;i<k;i++)ext[p[i]] = 1 , ans[p[i]] = 0; for (int i = 0;i<m;i++) { x = r[i][0]; y = r[i][1]; if (!ext[x])v[y].push_back({x , l[i]}); if (!ext[y])v[x].push_back({y , l[i]}); } bool f = true; while (f) { f = false; vector<int>thru[maxx]; for (int i = 0;i<n;i++) { if (ans[i] == INT_MAX)continue; for (auto to : v[i]) thru[to.F].push_back(to.S + ans[i]); } for (int i = 0;i<n;i++) { if (thru[i].size() < 2)continue; sort(thru[i].begin(),thru[i].end()); if (thru[i][1] < ans[i]) { f = true; ans[i] = thru[i][1]; } } } return ans[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...