i_n, i_m = input().split()
n = []
m = []
res = ""
n_excluded = []
for n_i in range(int(i_n)):
x1, y1, x2, y2 = input().split()
n.append({
"x1": int(x1), "y1": int(y1),
"x2": int(x2), "y2": int(y2)
})
for m_i in range(int(i_m)):
x, y = input().split()
m.append({
"x": int(x), "y": int(y)
for mm in m:
jar_num = 1
collision = False
for nn in n:
if jar_num not in n_excluded and nn['x1'] <= mm['x'] <= nn['x2'] and nn['y1'] <= mm['y'] <= nn['y2']:
collision = True
n_excluded.append(jar_num)
break
jar_num += 1
if collision:
res += " " + str(jar_num)
else:
res += " -1"
print(res)
Объяснение:
Это решение подходит только для E1. В E2 - ошибка Runtime Exception
ответ:
работает с e1, но в e2 выдает time limit exceeded на 57 тесте
объяснение:
m, n = map(int,
bank = []
bull = []
for i in range(m):
bank.append(list(map(int,
for i in range(n):
bull.append(list(map(int,
shoted = [true] * m
ns = [-1] * n
for j in range(m):
if bank[j][0] < = bull[i][0] < = bank[j][2] and bank[j][1] < = bull[i][1] < = bank[j][3] and shoted[j]:
shoted[j] = false
ns[i] = j + 1
for k in ns:
print(k, end=' ')
i_n, i_m = input().split()
n = []
m = []
res = ""
n_excluded = []
for n_i in range(int(i_n)):
x1, y1, x2, y2 = input().split()
n.append({
"x1": int(x1), "y1": int(y1),
"x2": int(x2), "y2": int(y2)
})
for m_i in range(int(i_m)):
x, y = input().split()
m.append({
"x": int(x), "y": int(y)
})
for mm in m:
jar_num = 1
collision = False
for nn in n:
if jar_num not in n_excluded and nn['x1'] <= mm['x'] <= nn['x2'] and nn['y1'] <= mm['y'] <= nn['y2']:
collision = True
n_excluded.append(jar_num)
break
jar_num += 1
if collision:
res += " " + str(jar_num)
else:
res += " -1"
print(res)
Объяснение:
Это решение подходит только для E1. В E2 - ошибка Runtime Exception
ответ:
работает с e1, но в e2 выдает time limit exceeded на 57 тесте
объяснение:
m, n = map(int,
bank = []
bull = []
for i in range(m):
bank.append(list(map(int,
for i in range(n):
bull.append(list(map(int,
shoted = [true] * m
ns = [-1] * n
for i in range(n):
for j in range(m):
if bank[j][0] < = bull[i][0] < = bank[j][2] and bank[j][1] < = bull[i][1] < = bank[j][3] and shoted[j]:
shoted[j] = false
ns[i] = j + 1
break
for k in ns:
print(k, end=' ')