디시인사이드 갤러리

마이너 갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

1162. As Far from Land as Possible

이벤트(1.226) 2023.02.10 20:19:57
조회 21 추천 0 댓글 0
														
class Solution {
public:
int maxDistance(vector<vector<int>>& grid) {
vector<int> water;
vector<int> land;
for(int i = 0; i < grid.size(); i++) {
for(int j = 0; j < grid.size(); j++) {
if(grid[i][j] == 0) {
water.push_back(i*grid.size() + j);
}
else {
land.push_back(i*grid.size() + j);
}
}
}
if(water.size() == 0 || land.size() == 0) {
return -1;
}
int ret = 0;
for(int w: water) {
int wy = w/grid.size();
int wx = w%grid.size();
int tmp = 1e8;
for(int l: land) {
int ly = l/grid.size();
int lx = l%grid.size();
tmp = min(tmp, abs(wx-lx) + abs(wy - ly));
}
ret = max(ret, tmp);
}
return ret;
}
};


오늘도 꼴찌 



ac5939a70001b942813e33669735c1bcc2a977c21c773585f0dabed5e42e074dc2d2532d4ea6fd28c8a114c2d1971e9ec2e2b1216c89d8c835211bc7a95813fa026785318688b5bc40d9c1e5



추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 2025년 가장 기억에 남는 인터넷 이슈는? 운영자 25/12/22 - -
214 1675. Minimize Deviation in Array 개발뉴비갤로그로 이동합니다. 23.02.25 26 0
212 1675. Minimize Deviation in Array chromate00갤로그로 이동합니다. 23.02.25 32 0
211 502. IPO 이벤트(1.226) 23.02.23 26 0
209 502. IPO 개발뉴비갤로그로 이동합니다. 23.02.23 30 0
208 502. IPO chromate00갤로그로 이동합니다. 23.02.23 31 0
207 1011. Capacity To Ship Packages Within D 이벤트(1.226) 23.02.22 16 0
206 1011. Capacity To Ship Packages Within D 개발뉴비갤로그로 이동합니다. 23.02.22 28 0
205 1011. Capacity To Ship Packages Within D chromate00갤로그로 이동합니다. 23.02.22 20 0
204 540. Single Element in a Sorted Array 개발뉴비갤로그로 이동합니다. 23.02.21 25 0
203 540. Single Element in a Sorted Array 이벤트(1.226) 23.02.21 13 0
202 540. Single Element in a Sorted Array chromate00갤로그로 이동합니다. 23.02.21 21 0
201 35. Search Insert Position 이벤트(1.226) 23.02.21 18 0
200 35. Search Insert Position 개발뉴비갤로그로 이동합니다. 23.02.20 28 0
199 35. Search Insert Position chromate00갤로그로 이동합니다. 23.02.20 27 0
198 103. Binary Tree Zigzag Level Order Trav 개발뉴비갤로그로 이동합니다. 23.02.19 23 0
196 103. Binary Tree Zigzag Level Order Trav chromate00갤로그로 이동합니다. 23.02.19 20 0
195 103. Binary Tree Zigzag Level Order Trav 이벤트(1.226) 23.02.19 18 0
194 226. Invert Binary Tree chromate00갤로그로 이동합니다. 23.02.18 14 0
193 226. Invert Binary Tree 개발뉴비갤로그로 이동합니다. 23.02.18 23 0
191 226. Invert Binary Tree 이벤트(1.226) 23.02.18 22 0
189 783. Minimum Distance Between BST Nodes 개발뉴비갤로그로 이동합니다. 23.02.18 18 0
188 783. Minimum Distance Between BST Nodes chromate00갤로그로 이동합니다. 23.02.17 19 0
187 783. Minimum Distance Between BST Nodes 이벤트(1.226) 23.02.17 24 0
186 104. Maximum Depth of Binary Tree 개발뉴비갤로그로 이동합니다. 23.02.17 23 0
185 104. Maximum Depth of Binary Tree 이벤트(1.226) 23.02.16 16 0
183 104. Maximum Depth of Binary Tree chromate00갤로그로 이동합니다. 23.02.16 42 0
182 989. Add to Array-Form of Integer 이벤트(1.226) 23.02.15 17 0
181 989. Add to Array-Form of Integer chromate00갤로그로 이동합니다. 23.02.15 19 0
180 989. Add to Array-Form of Integer 개발뉴비갤로그로 이동합니다. 23.02.15 20 0
179 67. Add Binary 개발뉴비갤로그로 이동합니다. 23.02.14 30 0
178 67. Add Binary 이벤트(1.226) 23.02.14 20 0
177 67. Add Binary chromate00갤로그로 이동합니다. 23.02.14 31 0
176 1523. Count Odd Numbers in an Interval R chromate00갤로그로 이동합니다. 23.02.14 25 0
175 1523. Count Odd Numbers in an Interval R 이벤트(1.226) 23.02.13 17 0
174 1523. Count Odd Numbers in an Interval R 개발뉴비갤로그로 이동합니다. 23.02.13 28 0
173 2477. Minimum Fuel Cost to Report to the 개발뉴비갤로그로 이동합니다. 23.02.13 26 0
172 구현 문제 풀 때 꿀팁? 구현력 기르는 꿀팁? 있으신가요 ? [1] ㅇㅇ(180.67) 23.02.12 51 0
170 2477. Minimum Fuel Cost to Report to the 이벤트(1.226) 23.02.12 23 0
169 2477. Minimum Fuel Cost to Report to the [1] chromate00갤로그로 이동합니다. 23.02.12 29 0
168 2477. Minimum Fuel Cost to Report to the ㅇㅇ(218.234) 23.02.12 20 0
167 1129. Shortest Path with Alternating Col 이벤트(1.226) 23.02.12 17 0
166 1129. Shortest Path with Alternating Col [1] 개발뉴비갤로그로 이동합니다. 23.02.11 54 0
165 1129. Shortest Path with Alternating Col chromate00갤로그로 이동합니다. 23.02.11 35 0
163 오늘의 데일리 (feat. ChatGPT) 개발뉴비갤로그로 이동합니다. 23.02.11 46 2
162 1162. As Far from Land as Possible chromate00갤로그로 이동합니다. 23.02.10 25 0
1162. As Far from Land as Possible 이벤트(1.226) 23.02.10 21 0
160 데일리 [1] ㅇㅇ(223.62) 23.02.10 38 0
159 오늘은 포기 이벤트(39.7) 23.02.09 32 1
158 2306. Naming a Company. chromate00갤로그로 이동합니다. 23.02.09 21 0
157 2306. Naming a Company 개발뉴비갤로그로 이동합니다. 23.02.09 41 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

디시미디어

디시이슈

1/2