Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. #include <queue>
  5.  
  6. using namespace std;
  7.  
  8. vector<vector<bool>> g(31, vector<bool> (31, 0));
  9. vector<bool> used(31, 0);
  10. queue<int> q;
  11. long long ans[31][2], type[31], pow[31];
  12.  
  13. void bfs(v) {
  14. q.push(v);
  15.  
  16. used[v] = true;
  17.  
  18. p = 30;
  19.  
  20. while (!q.empty()) {
  21. node = q.pop();
  22.  
  23. for (int i = 1; i <= n; i++) {
  24. if (g[node][i]) {
  25. if (!used[i]) {
  26. q.push(i);
  27. used[i] = true;
  28. t[i] = type;
  29. pow[i] = p;
  30. type = (type + 1) % 4;
  31. }
  32. }
  33. }
  34.  
  35. p--;
  36. }
  37. }
  38.  
  39. int main() {
  40.  
  41. ios_base::sync_with_stdio(false);
  42. cout.tie(nullptr);
  43. cin.tie(nullptr);
  44.  
  45. vector<int> cnt;
  46. int n, u, v;
  47.  
  48. cin >> n;
  49.  
  50. cnt.assign(n + 1, 0);
  51.  
  52. for (int i = 0; i < n - 1; i++) {
  53. cin >> u >> v;
  54.  
  55. g[u][v] = 1;
  56. g[v][u] = 1;
  57.  
  58. cnt[v]++;
  59. cnt[u]++;
  60.  
  61. if (cnt[v] == 5 || cnt[u] == 5) {
  62. cout << "NO";
  63. return 0;
  64. }
  65. }
  66.  
  67. ans[1][0] = 0;
  68. ans[1][1] = 0;
  69.  
  70.  
  71.  
  72. cout << "YES\n";
  73.  
  74. for (int i = 1; i <= n; i++) {
  75. cout << ans[i][0] << ' ' << ans[i][1] << '\n';
  76. }
  77.  
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement