BFS
#include using namespace std; typedef long long ll; typedef pair pii; int R, C; int board[100][100]; int dir8[2][8]{ {0, -1, 0, 1, -1, -1, 1, 1}, {1, 0, -1, 0, 1, -1, -1, 1} }; bool dup[100][100]; void bfs(pii init) { int cr, cc, nr, nc; queue que; dup[init.first][init.second] = true; for (que.push(init); !que.empty(); que.pop()) { tie(cr, cc) = que.front(); for (int i = 0; i < 4; ++i) { nr = cr..
2020. 12. 13.
Suffix Array와 LCP Array
#include using namespace std; typedef long long ll; typedef pair pii; vector suffixArray, LCPArray; void getLCP(vector& sa, vector& lcpa, string& s) { int i, j, k, l = 0, m = 26, sLen = s.length(); sa.resize(sLen, 0); lcpa.resize(sLen, 0); // cnt: radix cnt | x: rank vector cnt(max(sLen, m), 0), x(sLen, 0), y(sLen, 0); for (i = 0; i < sLen; ++i) cnt[x[i] = s[i] - 'a']++; for (i = 0; i < m; ++i) ..
2020. 9. 23.