Skip to content

Instantly share code, notes, and snippets.

Avatar

EVEerNew overnew

View GitHub Profile
@overnew
overnew / [BaekJoon]_13306_트리.cpp
Last active Mar 3, 2021
[BaekJoon]_13306_트리
View [BaekJoon]_13306_트리.cpp
#include<vector>
#include<cstdio>
using namespace std;
class DisjointSet{
public:
vector<int> parent;
DisjointSet(int n) : parent(n+1) {
for(int i=0; i<parent.size() ; ++i)
parent[i] = i;
@overnew
overnew / [BaekJoon]_17619_개구리 점프.cpp
Created Mar 1, 2021
[BaekJoon]_17619_개구리 점프
View [BaekJoon]_17619_개구리 점프.cpp
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
class DisjointSet{
public:
vector<int> parent, rank;
DisjointSet(int n) : parent(n+1), rank(n+1, 1) {
for(int i=0; i<parent.size() ; ++i)
@overnew
overnew / [BaekJoon]_4195_친구 네트워크.cpp
Created Mar 1, 2021
[BaekJoon]_4195_친구 네트워크
View [BaekJoon]_4195_친구 네트워크.cpp
#include<vector>
#include<map>
#include<cstdio>
#include<string>
using namespace std;
class DisjointSet{
public:
map<string, int> id_map;
vector<int> parent, set_size, rank;
@overnew
overnew / [BaekJoon]_1717_집합의 표현.cpp
Created Feb 28, 2021
[BaekJoon]_1717_집합의 표현
View [BaekJoon]_1717_집합의 표현.cpp
#include<vector>
#include<cstdio>
using namespace std;
class DisjointSet{
public:
vector<int> parent, rank;
DisjointSet(int n) : parent(n+1), rank(n+1,1) {
for(int i=0; i<parent.size() ; ++i)
parent[i]= i;
@overnew
overnew / [AlgoSpot]_EDITORWARS_에디터 전쟁.cpp
Created Feb 28, 2021
[AlgoSpot]_EDITORWARS_에디터 전쟁
View [AlgoSpot]_EDITORWARS_에디터 전쟁.cpp
#include<vector>
#include<iostream>
using namespace std;
int member_num, reply_num;
class DisjointSet{
public:
vector<int> parent, rank, set_size, enemy;
DisjointSet(int n) : parent(n), rank(n,1), set_size(n,1), enemy(n,-1) {
View [BaekJoon]_2934_LRH 식물.cpp
#include<vector>
#include<cstdio>
using namespace std;
const int TREESIZE = 100001;
class FenwickTree{
public:
vector<int> tree = vector<int>(TREESIZE);
@overnew
overnew / Fenwick Tree Lazy propagation.cpp
Created Feb 27, 2021
Fenwick Tree Lazy propagation
View Fenwick Tree Lazy propagation.cpp
const int TREESIZE = 1000001;
class LazyFenwickTree{
public:
vector<int> degree_tree = vector<int>(TREESIZE); //일차항 저장
vector<int> const_tree = vector<int>(TREESIZE); //상수항 저장
void RangeUpdate(int L, int R, int x){
Update(degree_tree, L, x); //B[L] += x로 update
Update(degree_tree, R+1, -x); //B[R+1] -= x로 update
@overnew
overnew / [AlgoSpot]_MEASURETIME_삽입 정렬 시간 재기.cpp
Created Feb 26, 2021
[AlgoSpot]_MEASURETIME_삽입 정렬 시간 재기
View [AlgoSpot]_MEASURETIME_삽입 정렬 시간 재기.cpp
#include<vector>
#include<cstdio>
using namespace std;
typedef long long ll;
class FenwickTree{
public:
vector<ll> tree = vector<ll>(1000001);
View [BaekJoon]_1395_스위치.cpp
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;
vector<int> segment_tree;
vector<int> lazy; //해당 구간의 스위치가 눌린횟수
void UpdateLazy(int left, int right, int node){
if(lazy[node] %2 == 1){ //홀수일때만 의미가 있다.
@overnew
overnew / [AlgoSpot]_FAMILYTREE_족보 탐험
Created Feb 23, 2021
[AlgoSpot]_FAMILYTREE_족보 탐험.cpp
View [AlgoSpot]_FAMILYTREE_족보 탐험
#include<vector>
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
const int MAX_N = 100000;
vector<vector<int>> child;
int no2serial[MAX_N], serial2no[MAX_N];