Submission #981824

#TimeUsernameProblemLanguageResultExecution timeMemory
981824FZ_MeloCyberland (APIO23_cyberland)C++17
0 / 100
1223 ms2097152 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; struct ari{ int node; double cnt; }; vector<vector<ari>> adj; int state[100000]; int n, m, k, fin; double ans; void dfs(int node, double cnt, int ant){ if(node==fin){ ans=min(ans, cnt); return; } for(auto h: adj[node]){ if(h.node==ant) continue; dfs(h.node, cnt+h.cnt, node); } } 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) { n=N; m=M; k=K; fin=H; adj.clear(); adj.resize(n); ans=(1<<30); for(int i=0; i<m; i++){ adj[x[i]].push_back({y[i], c[i]}); adj[y[i]].push_back({x[i], c[i]}); } for(int i=0; i<n; i++) state[i]=arr[i]; dfs(0, 0, 0); if(ans==(1<<30)) ans=-1; return ans; }

Compilation message (stderr)

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:34:41: warning: narrowing conversion of 'c.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'double' [-Wnarrowing]
   34 |         adj[x[i]].push_back({y[i], c[i]});
      |                                         ^
cyberland.cpp:35:41: warning: narrowing conversion of 'c.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'double' [-Wnarrowing]
   35 |         adj[y[i]].push_back({x[i], c[i]});
      |                                         ^
#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...