#35483: 簡單暴力python解

#### wmouo (crazypanda)

School : 國立宜蘭高級商業職業學校
ID : 178206
IP address : [42.71.103.184]
2024-05-22 14:19:03
k731. 1. 路徑偵測 -- | From: [118.165.145.156] | Post Date : 2023-06-04 21:04

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] += 1
elif now == 'u':
z[0] += 1
elif now == 'o':
z[1] += 1
now = 'r'
if a < r[0] :
if now == 'r':
z[2] += 1
elif now == 'o':
z[0] += 1
elif now == 'u':
z[1] += 1
now = 'l'
elif b != r[1]:
if b > r[1]:
if now == 'u':
z[2] += 1
elif now == 'r':
z[0] += 1
elif now == 'l':
z[1] += 1
now = 'o'
if b < r[1] :
if now == 'o':
z[2] += 1
elif now == 'l':
z[0] += 1
elif now == 'r':
z[1] += 1
now = 'u'
r = [a,b]
print(z[0],z[1],z[2])

#35490: Re: 簡單暴力python解

#### s11104220@school.saihs.edu.tw (施同學)

School : 臺北市立松山高級工農職業學校
ID : 221254
IP address : [118.165.14.31]
2024-06-17 17:43:35
k731. 1. 路徑偵測 -- | From: [123.193.213.137] | Post Date : 2023-06-04 21:52

0右1下2左3上
from sys import stdin
os=[0,0]
d=0
ans=[0,0,0]
for _ in range(n):
if os[0]<s[0]:
if d==1:ans[0]+=1
elif d==2:ans[2]+=1
elif d==3:ans[1]+=1
d=0
elif os[1]>s[1]:
if d==0:ans[1]+=1
elif d==2:ans[0]+=1
elif d==3:ans[2]+=1
d=1
elif os[0]>s[0]:
if d==0:ans[2]+=1
elif d==1:ans[1]+=1
elif d==3:ans[0]+=1
d=2
elif os[1]<s[1]:
if d==0:ans[0]+=1
elif d==1:ans[2]+=1
elif d==2:ans[1]+=1
d=3
os=s
print(*ans)

#35492: Re: 簡單暴力python解

#### s011388@fysh.tc.edu.tw (pollux)

School : 國立豐原高級中學
ID : 189768
IP address : [111.252.218.114]
2024-06-11 21:18:57
k731. 1. 路徑偵測 -- | From: [111.252.213.228] | Post Date : 2023-06-04 21:55

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] += 1
elif now == 'u':
z[0] += 1
elif now == 'o':
z[1] += 1
now = 'r'
if a < r[0] :
if now == 'r':
z[2] += 1
elif now == 'o':
z[0] += 1
elif now == 'u':
z[1] += 1
now = 'l'
elif b != r[1]:
if b > r[1]:
if now == 'u':
z[2] += 1
elif now == 'r':
z[0] += 1
elif now == 'l':
z[1] += 1
now = 'o'
if b < r[1] :
if now == 'o':
z[2] += 1
elif now == 'l':
z[0] += 1
elif now == 'r':
z[1] += 1
now = '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]))

#35502: Re: 簡單暴力python解

#### s11104220@school.saihs.edu.tw (施同學)

School : 臺北市立松山高級工農職業學校
ID : 221254
IP address : [118.165.14.31]