이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |