Submission #931030

#TimeUsernameProblemLanguageResultExecution timeMemory
931030tamir1Cyberland (APIO23_cyberland)C++17
0 / 100
3050 ms4440 KiB
#include "cyberland.h" #include <bits/stdc++.h> #include <vector> #define ff first #define ss second using namespace std; double ans1,ans2,ans; vector<pair<int,int>> v[100010]; vector<int> ar; bitset<100001> vis; int h; void dfs(int a,double dist,int k){ if(vis[a]) return; vis[a]=1; if(a==h){ ans=min(ans,dist); return; } for(pair<int,int> i:v[a]){ if(ar[a]==0) dfs(i.ff,i.ss,k); if(ar[a]==1) dfs(i.ff,dist+i.ss,k); if(ar[a]==2){ dfs(i.ff,dist+i.ss,k); if(k>0) dfs(i.ff,dist/2+i.ss,k-1); } } vis[a]=0; } double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { if(N==2){ if(M>0) return c[0]; else return -1; } if(N==3){ bool p=false,q=false; int d; for(int i=0;i<M;i++){ if((x[i]==0 && y[i]==H) || (x[i]==H && y[i]==0)){ p=true; ans1=c[i]; } else if(x[i]==0 || y[i]==0){ if(x[i]==0) d=y[i]; else d=x[i]; if(arr[d]==0) ans2=0; else if(arr[d]==1 || (arr[d]==2 && K<1)) ans2=c[i]; else ans2=c[i]/2; for(int j=0;j<M;i++){ if((x[j]==d && y[j]==H) || (x[j]==H && y[j]==d)){ q=true; ans2+=c[j]; } } } } if(!p && !q) return -1; if(!p) return ans2; if(!q) return ans1; return min(ans1,ans2); } return ans; }
#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...