模拟
只需模拟两个起点
- (0,0)
- (0,1)
方向都是UR
,模拟过程中统计消除的块,回到起点或者碰到角落就结束模拟。
n,***p(int,input().strip().split())
D *= 2
# 角落
corner = set()
corner.add((0,0))
corner.add((0,m))
corner.add((n,0))
corner.add((n,m))
# 起点,偏移量
def getRes(start,xc,yc):
x,y = start
t = 0
while True:
# 走到撞墙为止
while 0 <= x+xc <= n and 0 <= y+yc <= m:
nx,ny = x+xc,y+yc
if x+nx >= D:
t += 1
x,y = nx,ny
# 撞墙转向
if not y:
yc *= -1
elif not x:
xc *= -1
elif y == m:
yc *= -1
else:
xc *= -1
# 去到角落 或者 回到起点
if (x,y) in corner or (x,y) == start:
return t == m * (n-D//2)
if getRes((0,0),1,1):
print("YES")
print(0,0)
print("UR")
elif getRes((0,1),1,1):
print("YES")
print(0,1)
print("UR")
else:
print("NO")