Submission #970560

#TimeUsernameProblemLanguageResultExecution timeMemory
970560SuPythonyCyberland (APIO23_cyberland)C++17
8 / 100
2678 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; } for (auto v: al[i]) { if (v.first==p) continue; if (a[i]!=0) curr+=v.second; dfs(v.first,i,f,a); if (a[i]!=0) curr-=v.second; } } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> a) { curr=0; al.assign(1e5,vector<pair<int,int>>()); for (int i=0; i<M; i++) { al[x[i]].push_back({y[i],c[i]}); al[y[i]].push_back({x[i],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...