# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
521986 | 2022-02-03T14:45:37 Z | new_acc | 길고양이 (JOI20_stray) | C++14 | 0 ms | 0 KB |
#include<bits/stdc++.h> #include "Anthony.h" #define fi first #define se second #define rep(a, b) for(size_t a = 0; a < (size_t)(b); a++) using namespace std; typedef long long ll; typedef vector<ll> vi; typedef vector<ll> vl; const int N=2e4+10; int deg[N],kol[N]; bool vis[N]; vi graf[N]; void bfs(){ deque<int> deq; deq.push_back(0),vis[0]=1; while(deq.size()){ int v=deq.front(); deq.pop_front(); for(auto u:graf[v]){ if(!vis[u]){ deg[u]=deg[v]+1,vis[u]=1; deq.push_back(u); } } } } vi Mark(int n,int m,int a,int b,vi u,vi v){ rep(i,m) graf[u[i]].push_back(v[i]),graf[v[i]].push_back(u[i]); bfs(); rep(i,n) kol[i]=(i==0?0:(kol[i-1]+1)%3); vi res; rep(i,m) res.push_back(kol[min(deg[u[i]],deg[v[i]])]); return res; }