Submission #486403

#TimeUsernameProblemLanguageResultExecution timeMemory
486403BERNARB01Graph (BOI20_graph)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; int n, m; float a[16], vals[] = {-2, -1.5, -1, -.5, 0, .5, 1, 1.5, 2}; tuple<int, int, float> ed[16]; void sol(int i) { if (i == n) { bool bl = true; for (int j = 0; j < m; j++) { auto [u, v, w] = ed[j]; if (a[u] + a[v] != w) { bl = false; break; } } if (bl) { cout << "YES" << '\n'; for (int k = 0; k < n; k++) { if (k > 0) { cout << " "; } cout << a[k]; } cout << '\n'; exit(0); } return; } for (float x : vals) { a[i] = x; sol(i + 1); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; float w; cin >> u >> v >> w; --u; --v; ed[i] = {u, v, w}; } sol(0); cout << "NO" << '\n'; return 0; }
#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...