Submission #970574

#TimeUsernameProblemLanguageResultExecution timeMemory
970574SuPythonyCyberland (APIO23_cyberland)C++17
8 / 100
880 ms2097152 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<pair<int,int>>> al; double ans; double curr; void dfs(int i, int p, int f, vector<int> a) { if (i==f) { ans=curr; return; } double prev=curr; if (a[i]==0) curr=0.0; for (auto v: al[i]) { if (v.first==p) continue; curr+=v.second; dfs(v.first,i,f,a); if (a[i]==0) curr=0.0; else curr=prev; } curr=prev; } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> a) { curr=0.0; al.assign(N,vector<pair<int,int>>()); for (int i=0; i<M; i++) { al[x[i]].push_back({y[i],(double)c[i]}); al[y[i]].push_back({x[i],(double)c[i]}); } dfs(0,-1,H,a); 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...