Skip to content

Instantly share code, notes, and snippets.

View justiceHui's full-sized avatar
:octocat:
HelloWorld!

Jeounghui Nah justiceHui

:octocat:
HelloWorld!
View GitHub Profile
@justiceHui
justiceHui / priority_queue.js
Last active January 31, 2021 11:26
priority_queue.js
function priority_queue(comp){ this.arr = [], this.cmp = comp; }; //우선순위 큐
priority_queue.prototype.size = function(){ return this.arr.length; }; //우선순위 큐 크기
priority_queue.prototype._getPar = function(idx){ return Math.floor( (idx-1)/2 ); }; //부모 노드 구하기
priority_queue.prototype._getLeft = function(idx){ return (2*idx)+1; }; //왼쪽 자식 노드 구하기
priority_queue.prototype._getRight = function(idx){ return (2*idx)+2; }; //오른쪽 자식 노드 구하기
priority_queue.prototype.push = function(data){
if(this.size() == 0){
this.arr.push(data);
return;
}
void __swap(int *a, int *b) {
int tmp = *a;
*a = *b;
*b = tmp;
}
void __makeHeap(int *arr, int left, int right) {
for(int i=left; i<=right; i++) {
int now = i;
while(now > 0) {
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define pb push_back
using namespace std;
@justiceHui
justiceHui / FFT_Speed_Test.cpp
Last active May 29, 2020 03:25
FFT 성능 측정
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
/*
FFT_Recursion : https://justicehui.github.io/hard-algorithm/2019/09/04/FFT/
FFT_Recursion_Fast : https://namnamseo.tistory.com/entry/FFT-in-competitive-programming
FFT_Non_Recursion : https://blog.myungwoo.kr/54
NTT : https://algoshitpo.github.io/2020/05/20/fft-ntt/
Hell_Joseon_FFT : https://github.com/koosaga/DeobureoMinkyuParty
@justiceHui
justiceHui / simd_practice_1.cpp
Last active June 12, 2020 07:46
range sum query, range max query
#include <bits/stdc++.h>
#include <immintrin.h>
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
ll rangeSum(int *a, int s, int e){
ll ret = 0; int i;
__m256i avxSum = _mm256_setzero_si256();
@justiceHui
justiceHui / simd_practice_2.cpp
Created June 12, 2020 07:48
BOJ 2357 최솟값과 최댓값
#include <bits/stdc++.h>
#include <immintrin.h>
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
int n, q;
alignas(256) int a[101010];
const int inf = 1e9+7;
@justiceHui
justiceHui / tree_to_binary.cpp
Created September 14, 2020 01:02
트리 이진 변환
typedef long long ll;
typedef pair<ll, ll> p;
const int SZ = 303030;
vector<p> inp[SZ], g[SZ*2];
// now, real node, prev, adj list start index
void make_binary(int v = 1, int real = 1, int b = -1, int idx = 0){
for(int _i=idx; _i<inp[v].size(); _i++){ auto i = inp[v][_i];
if(i.x == b) continue;
if(g[real].empty()){
#define private public
#include <bitset>
#undef private
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
namespace FUCKING_STL_BITSET{
template<size_t _Nw> void _M_do_minus(_Base_bitset<_Nw> &A, const _Base_bitset<_Nw> &B){
for(int i=0, c=0; i<_Nw; i++) c=_subborrow_u64(c, A._M_w[i], B._M_w[i], (unsigned long long*)&A._M_w[i]);
@justiceHui
justiceHui / link-cut-tree.cpp
Last active January 4, 2021 09:03
link cut tree template
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9+7;
/// Knuth's Algorithm X with Dancing Link
namespace DLX{
struct Node{ int row, sz; shared_ptr<Node> col, up, dw, le, ri; };
using NP = shared_ptr<Node>;
void __Cover(NP x){
x->ri->le = x->le;