Submission #867592

#TimeUsernameProblemLanguageResultExecution timeMemory
867592thegamercoder19악어의 지하 도시 (IOI11_crocodile)C++14
100 / 100
410 ms77612 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #define M_PI 3.14159265358979323846 #define FILER 0 using ll = long long; using ull = unsigned long long; using ld = long double; const ll MOD = pow(10, 9) + 7; const ll INFL = 0x3f3f3f3f3f3f3f3f; const ull INFUL = 0x3f3f3f3f3f3f3f3f; const ll INFT = 0x3f3f3f3f; const ull MAX = 1LL << 24; const ll MODD = 998244353; const double EPS = 1e-10; #define V vector #define pll pair<ll, ll> #define pull2 pair<ull,ull> #define MS multiset //#define M map #define Q queue #define PQ priority_queue #define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c) #define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c) #define FORA(a,i) for(auto &i : a) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define sorta(a) sort(all(a)) #define sortd(a) sort(all(a), greater<ll>()) #define setp(x) setprecision(x)<<fixed #define RET return #define log(a,b) log(b)/log(a) #define WH(s) while(s) #define WHI(t) WH(t--) #define YES cout<<"YES"<<endl; #define NO cout<<"NO"<<endl; #define Yes cout<<"Yes"<<endl; #define No cout<<"No"<<endl; #define YESNO(s) cout << (s ? "YES" : "NO") << endl; #define YesNo(s) cout<<(s?"Yes":"No")<<endl; #define TYP 0 using namespace std; #include "crocodile.h" V<V<pll>> g, g1; V<bool> dp; V<pll> d; void dfs(ll u, ll p) { ll m = INFL, mu = -1; FORA(g1[u], v) if (v.first != p) { dfs(v.first, u); if (m > dp[v.first] + v.second) mu = v.first, m = dp[v.first] + v.second; } if (g1[u].size() != 1 || (g1[u].size()==1 && g1[u][0].first != p)) { m = INFL; FORA(g1[u], v) if (v.first != p && v.first != mu) m = min(m, dp[v.first] + v.second); dp[u] = m; } } void dijk(int& k, int* p) { PQ<pll, V<pll>, greater<pll>> pq; FOR(ll, i, 0, k, 1)pq.push({ 0,p[i] }), d[p[i]] = { 0,0 };// , dp[p[i]] = 1; WH(!pq.empty()) { ll du = pq.top().first, u = pq.top().second; pq.pop(); if (du != d[u].second || dp[u])continue; dp[u] = 1; FORA(g[u], v) { if (d[v.first].first > du + v.second) { d[v.first] = { du + v.second, d[v.first].first }; pq.push({ d[v.first].second , v.first }); } else if (d[v.first].second > du + v.second) { d[v.first] = { d[v.first].first , du + v.second}; pq.push({ d[v.first].second , v.first }); } } } } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { g.resize(N + 1); d.resize(N + 1, {INFL,INFL}); dp.resize(N + 1); FOR(ll, i, 0, M, 1)g[R[i][0]].push_back({ R[i][1], L[i] }), g[R[i][1]].push_back({ R[i][0], L[i] }); dijk(K, P); RET d[0].second; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...