Official
D - TaK Code Editorial by en_translator
Determine if “the nine-by-nine region whose top-left cell is the \(i\)-th row from the top and \(j\)-th column from the left” satisfies the conditions of TaK Code or not in lexicographical order of \((i,j)\), and print \((i,j)\) on the spot once the conditions are confirmed.
for i = 1..N-8 :
for j = 1..M-8 :
if the region whose top-left is (i,j) is applicable:
print(i,j)
Beware of the range of \(i\) and \(j\) loops to avoid out-of-range array reference.
You can determine if the region is applicable by the following function returning a boolean value.
func check(i, j):
// Check top-left black
for ii = 0..2 :
for jj = 0..2 :
if S[i+ii][j+jj] != '#':
return false
// Check bottom-right black
for ii = 6..8 :
for jj = 6..8 :
if S[i+ii][j+jj] != '#':
return false
// Check top-left white
for ii = 0..3:
if S[i+ii][j+3] != '.':
return false
for jj = 0..3:
if S[i+3][j+jj] != '.':
return false
// Check bottom-right white
for ii = 5..8:
if S[i+ii][j+5] != '.':
return false
for jj = 5..8:
if S[i+5][j+jj] != '.':
return false
// It satisfies everything
return true
posted:
last update: