Subscribed unsubscribe Subscribe Subscribe

0w1

CTF HR Infinite Links ( Web Crawler )

https://www.hackerrank.com/contests/capture-the-flag/challenges/infinite-links簡単な Web Crawler を書くだけ。 import urllib.request from queue import Queue def retrieve_msg_links( link ): line = list( urllib.request.urlopen( link ).read().…

AGC 12 B - Splatter Painting ( BFS )

B: Splatter Painting - AtCoder Grand Contest 012 | AtCoder題意: 給一張圖,以及 Q 次操作,每次操作將離 u 距離 d 內的所有節點塗色為 c。初始時每個節點顏色為 0。問所有操作結束後,每個節點分別顏色是什麼。資料規模: 1≦N,M,Q≦1e5 1≦ai,bi,vi≦N ai≠…

POI 2 Stage 2 The Right-Turn Drivers' Club ( DP, BFS )

http://main.edu.pl/en/archive/oi/2/kpk題意: 給一張圖,有若干障礙物,給始點和終點,問是否可以不左轉不倒回從始點走到終點,可以的話輸出最短路徑的方案。資料規模: In the first line of the standard input there are two integers separated by a s…

Yuki 157 2つの空洞 ( 0-1 BFS )

No.157 2つの空洞 - yukicoder 0-1 BFS (いらないけど #include <bits/stdc++.h> using namespace std; const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; int in_range( int h, int w, int x, int y ){ return 0 <= x and x < h and 0 <= y and y < w</bits/stdc++.h>…

CFR 129 C. Statues ( BFS )

Problem - C - Codeforces WA了一次,以為只會原地待著,或往上或往右或往右上移動。仔細想想,這全部方向都得考慮。 #include <bits/stdc++.h> using namespace std; const int MAXH = 8 + 2; const int MAXW = 8 + 2; typedef pair< int, int > pii; char G[ MAXH ][ MAXW</bits/stdc++.h>…

CFR 377 1A. Maze ( BFS + Reverse Thinking )

Problem - 377A - Codeforces 逆に連結成分を確保するという角度でやると簡単。 #include <bits/stdc++.h> using namespace std; const int MAXN = 500 + 5; const int MAXM = 500 + 5; const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; int n, m, k, </bits/stdc++.h>…

JOI 14 予選 Sandcastle ( BFS )

Sandcastle | Aizu Online Judge 更新されたマスだけまたqueueに入れる。バグ取るのに手間取った。 #include <bits/stdc++.h> using namespace std; const int MAXH = 1e3 + 3; const int MAXW = 1e3 + 3; typedef pair<int, int> pii; const int dx[] = { 0, 1, 0, -1, -1, 1, -1, 1 </int,></bits/stdc++.h>…

CFR Educational 1 D. Igor In the Museum ( Easy BFS )

Problem - D - Codeforces Simply simulating will be alright. #include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 3; const int MAXM = 1e3 + 3; const int MAXK = 1e6 + 6; const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; in</bits/stdc++.h>…

IOI'94 The Castle ( BFS )

PEG Judge - IOI '94 - The Castle 強行枚舉每個牆壁破壞後的樣子,直接把牆壁減掉,然後檢查完再加回來就行了。雖然很明顯,但要記得意識到只有破壞牆壁的連通分量會有面積的更新,所以不需要每次都檢查全部。有一點小小卡到的是後來枚舉破壞牆壁的時候忘記…

TPC追いコン A - 不完全迷路 ( BFS )

BFS

A: 不完全迷路 - TPC追いコン | AtCoder Short summary for statement: Given a graph where '.' indicates path and '#' indicates wall which shall not be penetrated, find the maximum distance from 'S' to 'G', where any but only one '#' can be ch…