Все задачи на 5.10.17 13:00
This commit is contained in:
24
uts/uts_2017_sum_py/5/C.py
Normal file
24
uts/uts_2017_sum_py/5/C.py
Normal 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)
|
||||
34
uts/uts_2017_sum_py/5/D.py
Normal file
34
uts/uts_2017_sum_py/5/D.py
Normal 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)
|
||||
5
uts/uts_2017_sum_py/5/rectangles.in
Normal file
5
uts/uts_2017_sum_py/5/rectangles.in
Normal 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
|
||||
1
uts/uts_2017_sum_py/5/robot.in
Normal file
1
uts/uts_2017_sum_py/5/robot.in
Normal file
@@ -0,0 +1 @@
|
||||
RSSSSLSLSSLS
|
||||
Reference in New Issue
Block a user