This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Node{ | |
Node *l, *r, *p; | |
bool flip; int sz; | |
Node(){ l = r = p = nullptr; sz = 1; flip = false; } | |
bool IsLeft() const { return p && this == p->l; } | |
bool IsRoot() const { return !p || (this != p->l && this != p->r); } | |
friend int GetSize(const Node *x){ return x ? x->sz : 0; } | |
void Rotate(){ | |
if(IsLeft()) r && (r->p = p), p->l = r, r = p; | |
else l && (l->p = p), p->r = l, l = p; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
OlderNewer