일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- scaled dot-product attention
- BoostCamp
- Prompt Tuning with Rules for Text Classification
- multi-head attention
- KLUE
- Chatbot
- ai-tech
- MT-DNN
- layer normalization
- Transformers
- 취업
- GPT-1
- pytorch
- fine-tuning
- beam search
- Eliza
- Relation Extraction
- Transformer
- FSML
- Conversation System
- NLP
- 백준
- bert
- text classification
- KLUE-RE
- huggingface
- Dialogue System
- BELU
- boj
- BLEU Score
Archives
- Today
- Total
dukim's blog
[BOJ-18405] 경쟁적 전염 본문
문제
https://www.acmicpc.net/problem/18405
내 풀이
바이러스가 있는 지점에서부터 BFS 수행, 이 떄 낮은 번호부터 시작하도록 정렬하여 시작할 것
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
from collections import deque
n, k = map(int, input().split())
board = []
for _ in range(n):
board.append(list(map(int, input().split())))
s, x_r, y_r = map(int, input().split())
len_col = len(board[0])
# moving
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
q = []
for x in range(n):
for y in range(len_col):
if board[x][y] != 0:
q.append((x, y, board[x][y], 0))
q = sorted(q, key=lambda x : x[2])
# BFS
q = deque(q)
depth = 0
while q:
x, y, v, depth = q.popleft()
if depth == s:
break
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if nx < 0 or nx >= n or ny < 0 or ny >= len_col:
continue
else:
if board[nx][ny] == 0:
board[nx][ny] = v
q.append((nx, ny, v, depth + 1))
print(board[x_r-1][y_r-1])
|
cs |
'Coding-Test' 카테고리의 다른 글
[BOJ-17409]증가 수열의 개수(in Python) (0) | 2021.07.03 |
---|---|
[BOJ-18428] 감시 피하기 (0) | 2021.03.03 |
Comments