avatar
m*l
1
题目是:
Provided with a grid with shaded cells.
Design a solution that finds the minimal distance to a shaded cell
avatar
b*e
2
"Design a solution that finds the minimal distance to a shaded cell"
from where?
avatar
q*x
3
Provided with a grid with shaded cells.
-- what is shaded cells?
Design a solution that finds the minimal distance to a shaded cell
-- from where?

【在 m********l 的大作中提到】
: 题目是:
: Provided with a grid with shaded cells.
: Design a solution that finds the minimal distance to a shaded cell

avatar
l*a
4
can't u see it from the image???
just consider the common cases,
give u another of two cells in the graph and get the minimal distance

【在 q****x 的大作中提到】
: Provided with a grid with shaded cells.
: -- what is shaded cells?
: Design a solution that finds the minimal distance to a shaded cell
: -- from where?

avatar
q*x
5

the "cell" could refer to one single grid element, or the cluster as a whole
. in the latter case, what is "distance"?

【在 l*****a 的大作中提到】
: can't u see it from the image???
: just consider the common cases,
: give u another of two cells in the graph and get the minimal distance

avatar
v*a
6
Basic shortest distance problem. Can use BFS.
avatar
a*m
7
看不懂。
avatar
m*l
8
my explanation is that bad?
=======================
"Design a solution that finds the minimal distance to a shaded cell"
from where?
from every empty cells.
I put in those negative numbers. the negative numbers are the distances
=====================
-- what is shaded cells?
图中灰色的东西
=====================

【在 a********m 的大作中提到】
: 看不懂。
avatar
c*m
9
就是说,数字是weight,但是这个不是点对点的最短路径了,终点可以是任一个shade
里面的点。
给定起点的话,就是 run 一遍dijistra(shade之间的权值设为inf),然后扫一遍
shade的边上的点。
avatar
a*m
10
这样的话跑一个dij就好了,碰到的第一个shade里面的返回就可以了吧。
avatar
o*t
11
On this particular picture, the question is super easy.
Observe that the cells next to shaded ones are all -1, and one cell further
are all -2 ...so on.
Therefore, from any arbitrary cell, just always look for the cell that has
the smallest ABS value, and walk that direction.

【在 m********l 的大作中提到】
: 题目是:
: Provided with a grid with shaded cells.
: Design a solution that finds the minimal distance to a shaded cell

avatar
m*l
12
Yup
But test yourself if you can do it during an interview.
There are at least 3 ways to solve this.

further

【在 o**********t 的大作中提到】
: On this particular picture, the question is super easy.
: Observe that the cells next to shaded ones are all -1, and one cell further
: are all -2 ...so on.
: Therefore, from any arbitrary cell, just always look for the cell that has
: the smallest ABS value, and walk that direction.

avatar
l*y
13
int dx={1,1,0,-1,-1,-1,0,1}
int dy={-,1,1,1,0,0,-1,-1,-1}
#define N 100
#define INTMAX 0x7FFFFF
int opt[N][N]=INTMAX;
int fill_cell(int i,int j)
{
if(grid[i][j]=='shade')
{ opt[i][j]=0; return 0;}
if(opt[i][j]==INTMAX){
opt[i][j]=min_0<=k<8{fill_cell(i+dx[k],j+dy[k])+1 if valid(i+dx[k],j+
dy[k])}

}
return opt[i][j];
}
avatar
z*u
14
are those numbers provided as known factor? Or provided by lz to illustrate
the problem?

further

【在 o**********t 的大作中提到】
: On this particular picture, the question is super easy.
: Observe that the cells next to shaded ones are all -1, and one cell further
: are all -2 ...so on.
: Therefore, from any arbitrary cell, just always look for the cell that has
: the smallest ABS value, and walk that direction.

avatar
m*l
15
I provided them; hoped to make it easier to understand.
Apparently, it ended up confusing people more.
The interviewer said:
You have a grid with shaded cells.
Then, start from the top-right corner, you have -7 to a shaded cell, then -6
to a shaded cell, etc.
Design a solution that finds all the distances to a shaded cell.

illustrate

【在 z****u 的大作中提到】
: are those numbers provided as known factor? Or provided by lz to illustrate
: the problem?
:
: further

avatar
s*n
16
这不就是个MDP么,学过AI的人都知道

-6

【在 m********l 的大作中提到】
: I provided them; hoped to make it easier to understand.
: Apparently, it ended up confusing people more.
: The interviewer said:
: You have a grid with shaded cells.
: Then, start from the top-right corner, you have -7 to a shaded cell, then -6
: to a shaded cell, etc.
: Design a solution that finds all the distances to a shaded cell.
:
: illustrate

avatar
l*y
17
这个是图形学问题,阴影部分代表三维模型,将三维模型放在一个3维网格内,计算每一个网格里模型的最近距离。学过volumetric rendering都知道。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。