# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
251804 | 2020-07-22T10:27:21 Z | imeimi2000 | Stray Cat (JOI20_stray) | C++17 | 0 ms | 0 KB |
#include "Anthony.h" #include <bits/stdc++.h> using namespace std; vector<int> Mark(int n, int m, int a, int b, vector<int> U, vector<int> V) { if (A > 2) { vector<int> dist(n, -1); vector<vector<int>> edge(n); for (int i = 0; i < m; ++i) { edge[U[i]].push_back(V[i]); edge[V[i]].push_back(U[i]); } queue<int> q; q.push(0); dist[0] = 0; while (!q.empty()) { int x = q.front(); for (int i : edge[x]) { if (dist[i] != -1) continue; q.push(i); dist[i] = dist[x] + 1; } } vector<int> ret(m); for (int i = 0; i < m; ++i) { int u = U[i], v = V[i]; if (dist[u] > dist[v]) swap(u, v); ret[i] = dist[u] % 3; } return ret; } }