백준 14466 소가 길을 건너간 이유 6 혼내주기
소에 index를 매긴 뒤 소마다 bfs를 돌아 index가 더 큰 소를 만나지 않는 횟수를 세주면 된다. 쌍을 구해야하는데 마리를 출력해서 헤맸다... #include #define fastio ios::sync_with_stdio(0), cin.tie(0) using namespace std; using ll = long long; using pii = pair; #define all(v) v.begin(), v.end() int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; bool roads[101][101][101][101], visited[101][101]; vector cows; int n, k, r..
혼내주기
2021. 10. 13. 02:24