Skip to content

Instantly share code, notes, and snippets.

@hjroh0315
hjroh0315 / valarraymatrix.cpp
Created January 23, 2022 11:17
엉엉 우리 Matrix 구조체가 일하고 있어요 너무 자랑스럽네요
#include<iostream>
#include<valarray>
using namespace std;
template<class T>
struct Matrix
{
valarray<T> data;
int dim,s;
Matrix(int R, int C):data(R*C),dim(C),s(R){}
@hjroh0315
hjroh0315 / chainedcomp.cpp
Created January 24, 2022 23:48
Chained Comparison인데, C++입니다
#include<iostream>
using namespace std;
template <class T>
struct cmp
{
T val; bool truthy;
cmp(T x): val(x), truthy(true){}
cmp(T x, bool b): val(x), truthy(b){}
cmp<T> operator<=(T v)
@hjroh0315
hjroh0315 / combifnd.cpp
Created January 26, 2022 10:21
이거 맞나????????
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;
const ll mod=10007;
ll mod_pow(int a,int n,int p)
{
ll ret=1;
@hjroh0315
hjroh0315 / 2ptrdeque.cpp
Last active January 27, 2022 14:36
투포인터(?) 덱 구현
#include<iostream>
using namespace std;
template<class T>
struct ptrDeque
{
using iterator=T*;
iterator l,r;
ptrDeque():l(new T),r(l){}
void push_back(T a){*r=a;r++;}
@hjroh0315
hjroh0315 / dcpowtmp.cpp
Created February 5, 2022 03:36
분할정복 거듭제곱을 TMP로 구현해 보았습니다. I made divide-and-conquer exponentiation with TMP
#include<iostream>
#include<type_traits>
using namespace std;
using ll=long long;
template<ll val>
struct value{
ll value=val;
};
template <ll val,ll cur,ll rem>
struct dcpow{};
@hjroh0315
hjroh0315 / enumerate.cpp
Created March 6, 2022 04:17
C++ enumerate (끔찍한 흑마술입니다)
#include<iostream>
#include<set>
#include<utility>
#include<cstdlib>
#include<ctime>
using namespace std;
template<class T>
struct enum_iter
{
@hjroh0315
hjroh0315 / random_hasher.cpp
Last active March 25, 2022 01:29
랜덤 시드를 활용한 해시 + 해시맵
#include<bits/stdc++.h>
using namespace std;
struct SingletonRand
{
size_t value;
SingletonRand()
{
auto curTime = chrono::system_clock::now(); auto duration = curTime.time_since_epoch();
auto timer = chrono::duration_cast<chrono::nanoseconds>(duration).count();
@hjroh0315
hjroh0315 / polyfft.cpp
Created April 6, 2022 13:41
FFT를 위한 Poly 클래스 (재귀) || Polynomial class for FFT (recursive)
#include<iostream>
#include<complex>
#include<vector>
#include<cmath>
#include<initializer_list>
using namespace std;
#define FLAG_DOROUND 1
const double Pi=acos(-1);
@hjroh0315
hjroh0315 / circular_buffer.cpp
Last active May 13, 2022 07:42
PS/CP를 위한 원형 큐 클래스. Range-based for를 통해 BFS를 할 수 있습니다. std::queue와 같은 함수 기능을 제공합니다. || Circular buffer class for Problem Solving/Competitive programming. Can be used with a range-based for statement in BFS. Provides the same functionality with std::queue.
#include<exception>
using namespace std;
//////// BEGIN STRUCT DEFINITION ////////
template<class T, size_t sz>
struct circular_buffer
{
struct It
{
circular_buffer<T,sz>&par;
@hjroh0315
hjroh0315 / heap.cpp
Last active April 23, 2022 02:30
힙을 구현하려고 했고, 구현했는데, 고장이네요. 엉엉ㅇㅇㅇ어어어어어어어ㅓㅇㅇㅇㅇㅇ
#include <iostream>
#include <vector>
using namespace std;
template<class T, class Comp=greater<T> >
struct heap{
vector<T> data;
Comp cmp;
heap(){data.push_back({});}
void push(T t){