台風で外出できない連休だったので,家でAtCoderをやっていた。今回はこれ。 Pの出力とQの出力の順番が異なっています。 heapqだとうまくいかなかった理由 今回のBFSの処理の中で以下のような処理があります。 現在地(nx, ny)に隣接する4方向を順番に調べてい ...
今回の記事ではいつもAtcoder中にpythonの普通のリストだと計算量的に間に合わないけどなんかデータ型使えば上手く行けたはず,,,ってのを記事にしてまとめておきます. リスト型の計算量について ・heapq.heapify(リスト)でリストを優先度付きキューに ...
A deque, also known as a double-ended queue, is an ordered collection of items with two ends, a front and a rear, and the items remain positioned in the collection. New items can be added at either ...
def insert_by_priority(task_deque, new_task): insert_by_priority(task_deque, simple_task_2) insert_by_priority(task_deque, simple_task_3) insert_by_priority(task ...