시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB165226330461837.520%

문제

송도에 사는 상근이와 친구들은 송도에서 열리는 펜타포트 락 페스티벌에 가려고 한다. 올해는 맥주를 마시면서 걸어가기로 했다. 출발은 상근이네 집에서 하고, 맥주 한 박스를 들고 출발한다. 맥주 한 박스에는 맥주가 20개 들어있다. 목이 마르면 안되기 때문에 50미터에 한 병씩 마시려고 한다. 즉, 50미터를 가려면 그 직전에 맥주 한 병을 마셔야 한다.

상근이의 집에서 페스티벌이 열리는 곳은 매우 먼 거리이다. 따라서, 맥주를 더 구매해야 할 수도 있다. 미리 인터넷으로 조사를 해보니 다행히도 맥주를 파는 편의점이 있다. 편의점에 들렸을 때, 빈 병은 버리고 새 맥주 병을 살 수 있다. 하지만, 박스에 들어있는 맥주는 20병을 넘을 수 없다. 편의점을 나선 직후에도 50미터를 가기 전에 맥주 한 병을 마셔야 한다.

편의점, 상근이네 집, 펜타포트 락 페스티벌의 좌표가 주어진다. 상근이와 친구들이 행복하게 페스티벌에 도착할 수 있는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 t가 주어진다. (t ≤ 50)

각 테스트 케이스의 첫째 줄에는 맥주를 파는 편의점의 개수 n이 주어진다. (0 ≤ n ≤ 100).

다음 n+2개 줄에는 상근이네 집, 편의점, 펜타포트 락 페스티벌 좌표가 주어진다. 각 좌표는 두 정수 x와 y로 이루어져 있다. (두 값 모두 미터, -32768 ≤ x, y ≤ 32767)

송도는 직사각형 모양으로 생긴 도시이다. 두 좌표 사이의 거리는 x 좌표의 차이 + y 좌표의 차이 이다. (맨해튼 거리)

출력

각 테스트 케이스에 대해서 상근이와 친구들이 행복하게 페스티벌에 갈 수 있으면 "happy", 중간에 맥주가 바닥나서 더 이동할 수 없으면 "sad"를 출력한다. 

예제 입력 1

2
2
0 0
1000 0
1000 1000
2000 1000
2
0 0
1000 0
2000 1000
2000 2000

예제 출력 1

happy
sad
W3sicHJvYmxlbV9pZCI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dGhlIEJlcmdraXJjaHdlaWguIFRoZSBsb2NhdGlvbiBpcyBnaXZlbiB3aXRoIHR3byBpbnRlZ2VyIGNvb3JkaW5hdGVzIHggYW5kIHksIChib3RoIGluIG1ldGVycywgLTMyNzY4ICZsZTsgeCwgeSAmbGU7IDMyNzY3KS48XC9wPlxyXG5cclxuPHA+QXMgRXJsYW5nZW4gaXMgYSByZWN0YW5ndWxhcmx5IGxhaWQgb3V0IGNpdHksIHRoZSBkaXN0YW5jZSBiZXR3ZWVuIHR3byBsb2NhdGlvbnMgaXMgdGhlIGRpZmZlcmVuY2Ugb2YgdGhlIGZpcnN0IGNvb3JkaW5hdGUgcGx1cyB0aGUgZGlmZmVyZW5jZSBvZiB0aGUgc2Vjb25kIGNvb3JkaW5hdGUgKGFsc28gY2FsbGVkIE1hbmhhdHRhbi1NZXRyaWMpLjxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPkZvciBlYWNoIHRlc3QgY2FzZSBwcmludCBvbmUgbGluZSwgY29udGFpbmluZyBlaXRoZXIgJmxkcXVvO2hhcHB5JnJkcXVvOyAoaWYgSm8gYW5kIGhpcyBmcmllbmRzIGNhbiBoYXBwaWx5IHJlYWNoIHRoZSBCZXJna2lyY2h3ZWloKSwgb3IgJmxkcXVvO3NhZCZyZHF1bzsgKGlmIHRoZXkgd2lsbCBub3QgcmVhY2ggdGhlJm5ic3A7QmVyZ2tpcmNod2VpaCBiZWNhdXNlIHRoZXkmbmJzcDtydW4gb3V0IG9mIGJlZXIuKS48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwiaHRtbF90aXRsZSI6IjAiLCJwcm9ibGVtX2xhbmdfdGNvZGUiOiJFbmdsaXNoIn1d

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2013 D번

  • 문제를 번역한 사람: baekjoon
  • 문제의 잘못된 점을 전체적으로 찾은 사람: jh05013
  • 어색한 표현을 찾은 사람: ljh6274
  • 문제의 오타를 찾은 사람: mwy3055
  • 데이터를 추가한 사람: rhdqor213