r = [0,0]z = [0,0,0]now = "r"for _ in range(int(input())):a,b = map(int,input().split())if a != r[0]:if a > r[0]:if now == 'l':z[2] += 1elif now == 'u':z[0] += 1elif now == 'o':z[1] += 1now = 'r'if a < r[0] :if now == 'r':z[2] += 1elif now == 'o':z[0] += 1elif now == 'u':z[1] += 1now = 'l'elif b != r[1]:if b > r[1]:if now == 'u':z[2] += 1elif now == 'r':z[0] += 1elif now == 'l':z[1] += 1now = 'o'if b < r[1] :if now == 'o':z[2] += 1elif now == 'l':z[0] += 1elif now == 'r':z[1] += 1now = 'u'r = [a,b]print(z[0],z[1],z[2])懶得想簡化方式了...有人有簡化方法可以提供一下嗎 哈哈哈
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
lis.insert(0,[0,0])
def dirc(lt):
if lt[0] > 0:return 1
if lt[0] < 0:return 3
if lt[1] > 0:return 2
if lt[1] < 0:return 4
def way(a,b):
if a == 1:
if b == 1:
return 0
if b == 2:
return 1
if b == 3:
return 3
if b ==4:
return 2
if a == 2:
if b == 1:
return 2
if b == 2:
return 0
if b == 3:
return 1
if b ==4:
return 3
if a == 3:
if b == 1:
return 3
if b == 2:
return 2
if b == 3:
return 0
if b ==4:
return 1
if a == 4:
if b == 1:
return 1
if b == 2:
return 3
if b == 3:
return 2
if b ==4:
return 0
ans = [0,0,0]
for i in range(1,len(lis)-1):
v1 = [lis[i][0]-lis[i-1][0],lis[i][1]-lis[i-1][1]]
v2 = [lis[i+1][0]-lis[i][0],lis[i+1][1]-lis[i][1]]
if way(dirc(v1),dirc(v2)):
n = way(dirc(v1),dirc(v2))-1
ans[n] += 1
print(" ".join([str(x) for x in ans]))
這樣有簡化嗎XD
右1上2左3下4