# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710200 | 2023-03-15T05:42:27 Z | MinhAnhnd | Stray Cat (JOI20_stray) | C++14 | 0 ms | 0 KB |
#include "Anthony.h" #include <vector> #include <bits/stdc++.h> namespace { int FunctionExample(int i, int A) { return i % A; } } // namespace std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) { std::vector<int> adj[20001]; int index[20001] = {}; std::vector<int> X(M); std::queue<int> bfs; bfs.push(0); index[0] = 1; for (int i = 0; i < M; ++i) { adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); } while(!bfs.empty()){ int node = bfs.back(); bfs.pop(); for(auto child:adj[node]){ if(index[child]==0){ index[child] = index[node] + 1; if(index[child]==4) index[child] = 1; bfs.push(child); } } } for (int i = 0; i < M; ++i) { int nodeA = index[U[i]]; int nodeB = index[V[i]]; if(nodeA > nodeB) std::swap(nodeA,nodeB); if((nodeA == 1)&&(nodeB == 2)) X[i] = 0; if((nodeA == 2)&&(nodeB == 3)) X[i] = 1; if((nodeA == 1)&&(nodeB == 3)) X[i] = 2; if((nodeA == 2)&&(nodeB == 2)) X[i] = 1; if((nodeA == 3)&&(nodeB == 3)) X[i] = 2; if((nodeA == 1)&&(nodeB == 1)) X[i] = 0; } return X; }