Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- #include <queue>
- using namespace std;
- vector<vector<bool>> g(31, vector<bool> (31, 0));
- vector<bool> used(31, 0);
- queue<int> q;
- long long ans[31][2], type[31], pow[31];
- void bfs(v) {
- q.push(v);
- used[v] = true;
- p = 30;
- while (!q.empty()) {
- node = q.pop();
- for (int i = 1; i <= n; i++) {
- if (g[node][i]) {
- if (!used[i]) {
- q.push(i);
- used[i] = true;
- t[i] = type;
- pow[i] = p;
- type = (type + 1) % 4;
- }
- }
- }
- p--;
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cout.tie(nullptr);
- cin.tie(nullptr);
- vector<int> cnt;
- int n, u, v;
- cin >> n;
- cnt.assign(n + 1, 0);
- for (int i = 0; i < n - 1; i++) {
- cin >> u >> v;
- g[u][v] = 1;
- g[v][u] = 1;
- cnt[v]++;
- cnt[u]++;
- if (cnt[v] == 5 || cnt[u] == 5) {
- cout << "NO";
- return 0;
- }
- }
- ans[1][0] = 0;
- ans[1][1] = 0;
- cout << "YES\n";
- for (int i = 1; i <= n; i++) {
- cout << ans[i][0] << ' ' << ans[i][1] << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement