1 / 6

Oh, My Goat!

Oh, My Goat!. 問題: kioa341 テスト: Respect2D. 問題概要. 2 つの DAG で共 通して出現する文章の数を求める 文章とは、 root から sink までの ラベルを連結した文字列. root. sink. haru. ake. bono. wa. natsu. saron. pusu. 解法. エッジ 2 つの ペアについて再帰処理 2 つの エッジとラベルの比較の開始位置について再帰 ラベルが一致したら開始位置を進める ラベルが一致しなかったら、打ち切り 開始位置が終端に至ったら、次のエッジ

wendi
Download Presentation

Oh, My Goat!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Oh, My Goat! 問題:kioa341 テスト: Respect2D

  2. 問題概要 • 2つのDAGで共通して出現する文章の数を求める • 文章とは、rootからsinkまでのラベルを連結した文字列 root sink haru ake bono wa natsu saron pusu

  3. 解法 • エッジ2つのペアについて再帰処理 • 2つのエッジとラベルの比較の開始位置について再帰 • ラベルが一致したら開始位置を進める • ラベルが一致しなかったら、打ち切り • 開始位置が終端に至ったら、次のエッジ • sinkノードに同時に到達したら、数える • sinkノードに一方だけ到達したら、数えない

  4. メモ再帰する • エッジの番号とラベルの位置でメモする • intdp[エッジ1][エッジ2][ラベル1][ラベル2]; • 600 × 600 × 5 × 5 ×4byte > 32MB • ラベルの始点のみでメモする • intdp[エッジ1][エッジ2]; • 600 ×600 × 4byte < 32MB • 計算時間は、(エッジ数)^2×(ラベル長)

  5. ラベルの管理が面倒なら • 辺のラベル文字列を1文字ずつ分割 • 分割前のエッジについてのみメモ

  6. 結果 • First Accept • 34分:cosさん • Accept/Submit • 11/24

More Related