Skip to content

Conversation

jerry0339
Copy link
Member

No description provided.

Comment on lines +55 to +57
for (Tiii next : adj.get(i)) { // 1번 바이러스들 부터 큐에 순차적으로 저장
q.add(next);
vi[next.y][next.x] = true; // 방문처리
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 우선순위 큐로 날짜까지 저장해서 순차적으로 바이러스 셀에 접근할 수 있도록 했는데 이걸 보니 그냥 1번 바이러스부터 큐에 넣어주기만 하면 되는 거였네요... 간단한 방법인데 막상 풀 때는 생각이 안났네요 ㅋㅋㅋ


public class Main{
static int N, M;
static ArrayList<ArrayList<Integer>> adj;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

풀이 자체는 비슷한 것 같은데 제 코드는 메모리가 47404KB, 찬의님 코드는 메모리가 33872KB가 나오더라구요. 왜 그런가 찾아봤는데 저는 Map을 사용하고 찬의님은 ArrayList를 사용해서 그런 것 같습니다. 스택오버플로우의 답변을 보니까 HashMap이 키, 값을 둘 다 저장해야 하고 load factor를 유지하기 위해서 메모리를 좀 더 많이 소모한다고 하더라구요. 저도 ArrayList를 활용하는 방안으로 풀이를 작성해야겠습니다.

@jerry0339 jerry0339 merged commit f33e333 into be/b/전찬의 Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants