Lowest Common Ancestor (LCA) 예제 코드
·
PS
#include #include using namespace std; int n, par[14][10001] = {{0}}, depth_arr[10001] = {0}; void bootstrap(void) { for (int i = 1; i = depth(v)) u = par[i][u]; } if (u == v) return u; for (int i = 13; i >= 0; i--) { if (par[i][u] != par[i][v]) { u = par[i][u]; v = par[i][v]; } } return par[0][u]; } int main(void) { scanf("%d", &n..
Lazy Propagation Segment Tree
·
PS
wx+b 연산을 지원하는 lazy 세그 예제 #include #include using namespace std; #define TREE_WIDTH (1
백준 9212 (트라이앵글)
·
PS
#include #include #include using namespace std; #define EPS (1.0e-15) class Vector3 { public : double x, y, z; Vector3() { x = 0.0; y = 0.0; z = 0.0; } Vector3(double _x, double _y, double _z) { x = _x; y = _y; z = _z; } Vector3 operator+(const Vector3 &v) const { return Vector3(x + v.x, y + v.y, z + v.z); } Vector3 operator-(const Vector3 &v) const { return Vector3(x - v.x, y - v.y, z - v.z); }..
zanzun
zanzun blog