티스토리 뷰
728x90
문제 링크
https://www.acmicpc.net/problem/15784
해당되는 칸을 기준으로 같은 행, 같은 열에 그 칸보다 높은 값을 가진 칸이 없는지 확인하면 된다.
행과 열에서 따로따로 확인하자.
정답 코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int n, p[1001][1001]; | |
int x, y; | |
int main() { | |
ios_base::sync_with_stdio(false); | |
cin.tie(0); | |
cin >> n; | |
cin >> x >> y; | |
x--; y--; | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < n; j++) { | |
cin >> p[i][j]; | |
} | |
} | |
for (int i = 0; i < n; i++) { | |
if (p[i][y] > p[x][y]) { | |
cout << "ANGRY"; | |
return 0; | |
} | |
if (p[x][i] > p[x][y]) { | |
cout << "ANGRY"; | |
return 0; | |
} | |
} | |
cout << "HAPPY"; | |
} |
728x90
'알고리즘 > 문제 풀이' 카테고리의 다른 글
[BOJ] 백준 15916 가희는 그래플러야!! (0) | 2018.07.25 |
---|---|
[BOJ] 백준 1010 다리 놓기 (3) | 2018.07.09 |
[BOJ] 백준 12888 완벽 이진 트리 도로 네트워크 (0) | 2018.07.05 |
[2018 IUPC] 백준 15782 Calculate! 2 (4) | 2018.06.29 |
[2018 IUPC] 백준 15781 헬멧과 조끼 (0) | 2018.06.29 |
댓글