Submission #486403

# Submission time Handle Problem Language Result Execution time Memory
486403 2021-11-11T15:00:45 Z BERNARB01 Graph (BOI20_graph) C++17
0 / 100
1 ms 204 KB
#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
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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -