티스토리 뷰

728x90

문제 링크

https://www.acmicpc.net/problem/15784


해당되는 칸을 기준으로 같은 행, 같은 열에 그 칸보다 높은 값을 가진 칸이 없는지 확인하면 된다.

행과 열에서 따로따로 확인하자.



정답 코드

#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";
}
view raw 15784.cpp hosted with ❤ by GitHub
728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함