Все задачи на 5.10.17 13:00

This commit is contained in:
2017-10-05 13:08:02 +03:00
parent 93746b05d7
commit ca2ca71f63
120 changed files with 2343 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import sys
sys.stdin = open('robot.in', 'r')
s = input()
d = 0
a = []
f = 0
c = 0
x = 0
y = 0
for i in s:
if i == 'S':
if (x, y) in a:
print(c)
exit()
a.append((x, y))
c += 1
if d == 0:
x += 1
if d == 1:
y += 1
if d == 2:
x -= 1
if d == 3:
y -= 1
if i == 'L':
d = (d + 1) % 4
if i == 'R':
d = (d - 1) % 4
if (x, y) in a:
print(c)
else:
print(-1)