# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975748 | Nexus | Cyberland (APIO23_cyberland) | C++17 | 1567 ms | 2097152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define ll long long
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
const ll N=1e5+9;
ll a[N],h,k;
bool balt;
vector<ll>v[N],r;
map<pair<ll,ll>,double>m;
void dfs(ll node,ll pa)
{
if(node==h)
{
r.push_back(node);
balt=1;
return;
}
//cout<<node<<' ';
for(auto i:v[node])
{
if(i!=pa)
dfs(i,node);
if(balt)
{
r.push_back(node);
return;
}
}
}
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
h=H,k=K;
for(ll i=0;i<M;++i)
{
v[x[i]].push_back(y[i]);
v[y[i]].push_back(x[i]);
m[{x[i],y[i]}]=c[i];
m[{y[i],x[i]}]=c[i];
}
dfs(0,0);
if(!balt)return -1;
reverse(r.begin(),r.end());
//cout<<r.size();
ll s=0;
for(ll i=0;i<r.size();++i)
{
//cout<<r[i]<<' ';
if(!arr[r[i]])s=i;
}
for(ll i=r.size()-1;i>=s;--i)
{
//cout<<r[i]<<' ';
if(arr[r[i]]==2 && k)--k,a[i]=1;
}
double ans=0;
for(ll i=s;i<r.size()-1;++i)
{
//cout<<m[{r[i],r[i+1]}]<<' ';
if(a[i])ans/=2.0;
ans+=m[{r[i],r[i+1]}];
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |