Submission #380301

#TimeUsernameProblemLanguageResultExecution timeMemory
380301Pichon5Shortcut (IOI16_shortcut)C++17
23 / 100
2081 ms492 KiB
#include "shortcut.h" #include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair //salida rapida "\n" //DECIMALES fixed<<sp(n)<<x<<endl; //gcd(a,b)= ax + by //lCB x&-x //set.erase(it) - ersases the element present at the required index//auto it = s.find(element) //set.find(element) - iterator pointing to the given element if it is present else return pointer pointing to set.end() //set.lower_bound(element) - iterator pointing to element greater than or equal to the given element //set.upper_bound(element) - iterator pointing to element greater than the given element // | ^ //__builtin_popcount(x) using namespace std; long long find_shortcut(int n, vi l, vi d, int c){ ll res=1e18; for(int i=0;i<n;i++){ for(int L=i+1;L<n;L++){ ll diametro=0; for(int k=0;k<n;k++){ vll peso(n+1,1e18); peso[k]=0ll; priority_queue<pair<ll,int> >q; q.push({0,k}); vector<bool>vis(n+1,false); while(!q.empty()){ int u=int(q.top().S); q.pop(); if(vis[u])continue; vis[u]=true; if(u+1<n && peso[u+1]>peso[u]+l[u]){ peso[u+1]=peso[u]+l[u]; q.push({-peso[u+1],u+1}); } if(u-1>=0 && peso[u-1]>peso[u]+l[u-1]){ peso[u-1]=peso[u]+l[u-1]; q.push({-peso[u-1],u-1}); } if(i==u && peso[L]>peso[u]+c){ peso[L]=peso[u]+c; q.push({-peso[L],L}); } if(L==u && peso[i]>peso[u]+c){ peso[i]=peso[u]+c; q.push({-peso[i],i}); } } if(d[k]>diametro)diametro=d[k]; for(int j=0;j<n;j++){ if(j==k)continue; diametro=max(diametro,peso[j]+d[j]+d[k]); } } res=min(res,diametro); } } return res; //9 30 10 10 10 10 10 10 10 10 20 0 30 0 0 40 0 40 0 //4 10 10 20 20 0 40 0 30 }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...