我們可以紀錄每一個人的
之後用兩個迴圈分別檢查直行橫列的座位,
找到其中的最大值。
要注意的是自己那一個座位的答案不能算。
let arr[][] denote the seat
let X[] denote the X-coordinate
let Y[] denote the Y-coordinate
c := 0
ans := 0
int main() {
input and record X[] and Y[].
input c
for (i = 0 ~ n)
if (arr[i][Y[c]] != c)
ans = max(ans, arr[i][Y[c]])
for (j = 0 ~ m)
if (arr[X[c]][j] != c)
ans = max(ans, arr[X[c]][j])
output ans
}
題目在問
所以就照著題意下去做就好了。
double distance(x1, y1, x2, y2) {
return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))
}
bool isValid(a, b, c, baba[], mie[], miao[], x, y) {
aa := 0
bb := 0
cc := 0
for each (x_i, y_i) in baba:
if distance(x, y, x_i, y_i) <= 10: aa := 1
for each (x_i, y_i) in mie:
if distance(x, y, x_i, y_i) <= 10: bb := 1
for each (x_i, y_i) in miao:
if distance(x, y, x_i, y_i) <= 12: cc := 1
return aa && bb && cc
}