Все задачи на 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,24 @@
#import sys
#sys.stdin = open('rectangles.in', 'r')
#sys.stdout = open('rectangles.out', 'w')
n, m, k = map(int, input().split())
a = [[100000, 0, 100000, 0] for i in range(k)]
field = []
for i in range(n):
field.append(list(map(int, input().split())))
field.reverse()
for i in range(n):
for j in range(m):
if field[i][j] > 0:
v = field[i][j] - 1
a[v][0] = min(a[v][0], j)
a[v][1] = max(a[v][1], j)
a[v][2] = min(a[v][2], i)
a[v][3] = max(a[v][3], i)
for i in range(k):
print(a[i][0], a[i][2], a[i][1] + 1, a[i][3] + 1)

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)

View File

@@ -0,0 +1,5 @@
4 5 2
0 2 2 2 2
0 2 2 2 2
1 1 2 2 2
1 1 0 0 0

View File

@@ -0,0 +1 @@
RSSSSLSLSSLS