Submission #859303

#TimeUsernameProblemLanguageResultExecution timeMemory
859303maks007Graph (BOI20_graph)C++14
0 / 100
2 ms344 KiB
#include "bits/stdc++.h" using namespace std; #define int long long signed main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector <pair <int, double>> g[n]; vector <double> node(n, (double)1e9), ans(n); double mn = 1e9; function<void(int)> rec=[&](int i) { // cout << i << " "; if(i==n) { for(int j = 0; j < n; j ++) { for(auto [k, w] : g[j]) { if(node[k] + node[j] == w) continue; return; } } double sum = 0.0; for(auto i : node) sum += i; // cout << mn << " "; ans = node; mn = min(mn, sum); return; } for(double val = -5; val < 5; val += 0.5) { node[i] = val; rec(i+1); node[i] = 1e9; } }; for(int i = 0; i < m; i ++) { int u, v; cin >> u >> v; u --, v --; int w; cin >> w; g[u].push_back({v, w}); g[v].push_back({u, w}); } rec(0); cout << fixed << setprecision(6) << mn << "\n"; for(auto i : ans) cout << fixed << setprecision(6) << i << " "; return 0; }

Compilation message (stderr)

Graph.cpp: In lambda function:
Graph.cpp:19:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |     for(auto [k, w] : g[j]) {
      |              ^
#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...