Submission #985014

#TimeUsernameProblemLanguageResultExecution timeMemory
985014kimCyberland (APIO23_cyberland)C++17
8 / 100
369 ms8908 KiB
#include "cyberland.h" #include<bits/stdc++.h> using namespace std; using db=double; using pii=pair<int,int>; using ll=long long; #define eb emplace_back #define f first #define s second const db eps=1e-2; using A=pair<int,db>; using B=pair<A,int>; struct cmp{ bool operator()(const B &l,const B &r)const{ if(l.f.f!=r.f.f) return l.f.f>r.f.f; return l.f.s-r.f.s > eps; } }; vector<pii> adj[100005]; A d[100005]; priority_queue<B,vector<B>,cmp> pq; double solve(int N, int M, int K, int H, std::vector<int> U, std::vector<int> V, std::vector<int> W, std::vector<int> arr) { for(int i=0;i<N;++i) adj[i].clear(); for(int i=0;i<M;++i) adj[U[i]].eb(V[i],W[i]), adj[V[i]].eb(U[i],W[i]); function<void(ll)> dijk=[&](ll lim){ while(!pq.empty()) pq.pop(); pq.emplace(A(0,0),0); d[0]={0,0}; for(int i=1;i<N;++i){ if(arr[i]==0) pq.emplace(A(0,0),i), d[i]={0,0}; else d[i]={1e9,0}; } while(!pq.empty()){ auto [w,u]=pq.top(); pq.pop(); if(u==H) return; for(auto &[v,vw]:adj[u]){ A w2={w.f,w.s+vw}; if(arr[v]==2 && w2.s-lim>eps) ++w2.f, w2.s/=2; if(d[v].f>w2.f || d[v].f==w2.f&&d[v].s-w2.s>eps){ d[v]=w2; pq.emplace(w2,v); } } } }; ll l=0,r=1e14; while(l<r){ ll mid=(l+r>>1); dijk(mid); if(d[H].f>K) l=mid+1; else r=mid; } return d[H].s; }

Compilation message (stderr)

cyberland.cpp: In lambda function:
cyberland.cpp:43:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   43 |                 if(d[v].f>w2.f || d[v].f==w2.f&&d[v].s-w2.s>eps){
      |                                   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:53:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   53 |         ll mid=(l+r>>1);
      |                 ~^~
#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...