#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
answer = YES |
2 |
Incorrect |
1 ms |
204 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
answer = YES |
2 |
Incorrect |
1 ms |
204 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
answer = YES |
2 |
Incorrect |
1 ms |
204 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
answer = YES |
2 |
Incorrect |
1 ms |
204 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
answer = YES |
2 |
Incorrect |
1 ms |
204 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |