# BFS # 스까묵자
#include<iostream> #include<cstdio> #include<vector> #include <deque> #include <string.h> #include <algorithm> using namespace std; long long ans; typedef pair<int, int> pa; int n, arr[100][100], che[100][100]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", arr[i] + j); } } deque<pa> dq; dq.push_back({ 0, 0 }); while (!dq.empty()) { pa now = dq.front(); dq.pop_front(); che[now.first][now.second] = 1; if (arr[now.first][now.second] == -1) continue; if (now.first + arr[now.first][now.second] < n) { if (che[now.first + arr[now.first][now.second]][now.second] == 0) { che[now.first + arr[now.first][now.second]][now.second] = 1; dq.push_back({ now.first + arr[now.first][now.second], now.second }); } } if (now.second + arr[now.first][now.second] < n) { if (che[now.first][now.second + arr[now.first][now.second]] == 0) { che[now.first][now.second + arr[now.first][now.second]] = 1; dq.push_back({ now.first, now.second + arr[now.first][now.second] }); } } } if (che[n - 1][n - 1] == 0) { printf("Hing\n"); } else { printf("HaruHaru\n"); } }
'IT > BOJ' 카테고리의 다른 글
백준(BOJ) 16190 Rising Sun ** (0) | 2018.10.07 |
---|---|
백준(BOJ) 16192 Voronoi Diagram Returns * (0) | 2018.10.07 |
백준(BOJ) 16172 나는 친구가 적다 ** (0) | 2018.10.04 |
백준(BOJ) 16169 수행시간 * (0) | 2018.10.04 |
백준(BOJ) 16168 퍼레이드 ** (0) | 2018.10.04 |