# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
517082 | 2022-01-22T13:41:38 Z | Ai7081 | Stations (IOI20_stations) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1005; int cnt, cnt2; vector<int> ret; vector<vector<int>> adj; void dfs(int v, int p) { ret[v] = 1000*cnt2 + cnt; //cout << v << ' ' << ret[v] << endl; cnt2++; for (auto to : adj[v]) { if (to != p) { dfs(to, v); } } return; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { adj.assign(n, vector<int>()); for (int i=0; i<(int)u.size(); i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } for (int i=0; i<n; i++) { if (adj[i].size() > 2) { ret.assign(n, 0); ret[i] = 0; cnt = 1; for (auto x : adj[i]) { cnt2 = 0; dfs(x, i); cnt++; } break; } } return ret; }