Skip to content

Commit b6044ee

Browse files
committed
2021.01.07
1 parent 54545b8 commit b6044ee

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

python/plat5/10165.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
N = int(input())
5+
6+
M = int(input())
7+
arr = []
8+
for i in range(M):
9+
a,b = map(int,input().split())
10+
if a>b:
11+
arr.append([a,b+N, i+1])
12+
else:
13+
arr.append([a,b,i+1])
14+
arr.append([a+N,b+N, i+1])
15+
16+
arr.sort(key= lambda x:(x[0],-x[1]))
17+
18+
19+
right = 0
20+
ans_set = set(range(1,M+1))
21+
for st,ed,idx in arr:
22+
if ed<=right:
23+
if idx in ans_set:
24+
ans_set.remove(idx)
25+
else:
26+
right = ed
27+
print(' '.join(map(str,list(ans_set))))

python/plat5/1028.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import sys
2+
input = sys.stdin.readline
3+
R, C = map(int,input().split())
4+
arr = []
5+
arr = [list(input().strip()) for _ in range(R)]
6+
for y in range(R):
7+
for x in range(C):
8+
arr[y][x]=int(arr[y][x])
9+
visited = [[False]*C for _ in range(R)]
10+
ans = 0
11+
12+
def checkdia2(y,x,size):
13+
while size>0:
14+
y+=1
15+
size-=1
16+
if arr[y][x-size] & arr[y][x+size]:continue
17+
return False
18+
return True
19+
20+
def checkdia(y,x):
21+
size = 1
22+
global ans
23+
if ans==0:ans=1
24+
max_size = min(C-x,x+1,(R-y+1)//2)
25+
if max_size<ans:return
26+
while size<max_size:
27+
y+=1
28+
if arr[y][x-size] & arr[y][x+size]:
29+
if size>=ans:
30+
if checkdia2(y,x,size):
31+
ans = size+1
32+
size+=1
33+
else:
34+
break
35+
36+
for y in range(R):
37+
for x in range(C):
38+
if arr[y][x]:
39+
checkdia(y,x)
40+
print(ans)

python/plat5/1306.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sys
2+
from collections import deque
3+
input = sys.stdin.readline
4+
output = sys.stdout.write
5+
6+
N, M = map(int,input().split())
7+
8+
arr = list(map(int,input().split()))
9+
10+
window = deque()
11+
L = 2*M-1
12+
for idx,light in enumerate(arr):
13+
if window and window[0][1]<=idx-L:
14+
window.popleft()
15+
while window and window[-1][0]<light:
16+
window.pop()
17+
window.append([light,idx])
18+
if idx>=L-1:
19+
output("%d "%window[0][0])

python/plat5/3163.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
from collections import deque
3+
input = sys.stdin.readline
4+
5+
6+
T = int(input())
7+
while T:
8+
T-=1
9+
N, L, K = map(int,input().split())
10+
left,right = [],[]
11+
id_list = []
12+
for _ in range(N):
13+
p, id = map(int,input().split())
14+
id_list.append(id)
15+
if id<0:
16+
left.append(p)
17+
else:
18+
right.append(L-p)
19+
ans = []
20+
for idx,l in enumerate(left):
21+
ans.append([l,id_list[idx]])
22+
for idx,r in enumerate(right,len(ans)):
23+
ans.append([r,id_list[idx]])
24+
ans.sort(key=lambda x:(x[0],x[1]))
25+
print(ans[K-1][1])

0 commit comments

Comments
 (0)