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
(() => { | |
const cvs = document.getElementById('cvs'); | |
const ctx = cvs.getContext('2d'); | |
function toHex(r, g, b){ | |
return "#" + ("000000" + ((r << 16) | (g << 8) | b).toString(16)).slice(-6); | |
} | |
function getColor(ctx, x, y) { | |
let w = cvs.width / 8, h = cvs.height / 15; |
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
// [l, r] | |
template <typename T> | |
void qsort(T a[], int left, int right) { | |
if (left >= right) return; | |
T mid = a[(left + right) / 2]; | |
int l = left, r = right; | |
while (l <= r) { | |
while (a[l] < mid) l++; | |
while (mid < a[r]) --r; | |
if (l <= r) { |
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
import sys | |
sys.setrecursionlimit(10 ** 6) | |
def is_json(json): | |
return type(json) == type({}) | |
def is_list(lst): | |
return type(lst) == type([]) |
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 <cstdio> | |
#include <vector> | |
#include <queue> | |
using namespace std; | |
typedef long long lld; | |
struct node { | |
node(lld d, int p) : data(d), prev(p) {} | |
lld data; |
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; | |
#define FOR(i, n) for(int i=0; i<(n); ++i) | |
#define REP(i, a, b) for(int i=(a); i<(b); ++i) | |
#define all(v) (v).begin(), (v).end() | |
#define SIZE(v) ((int)(v).size()) | |
typedef long long lld; | |
typedef pair<int, int> ii; |
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
from itertools import permutations | |
# AB*C = DE-F = GH/I | |
def validate(a): | |
ABC = (10*a[0] + a[1]) * a[2] | |
DEF = (10*a[3] + a[4]) - a[5] | |
if ABC != DEF: | |
return False | |
GH, I = 10*a[6] + a[7], a[8] | |
if GH % I != 0 or ABC != (GH / 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
# Homebrew Formula for Google Test | |
# Usage: brew install --HEAD https://gist.githubusercontent.com/joonas-yoon/9ec4ce1c1374ba8b8473020ced3879d8/raw/gtest.rb | |
require 'formula' | |
class Gtest < Formula | |
desc "Google Test" | |
homepage "https://github.com/google/googletest" | |
head "git://github.com/google/googletest.git", :using => :git |
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; | |
typedef long long lld; | |
typedef pair<int, int> ii; | |
const int INF = 0x3f3f3f3f; | |
const lld LNF = 0x3f3f3f3f3f3f3f3f; | |
const int MOD = 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
#include <bits/stdc++.h> | |
using namespace std; | |
#define MAX_N 100001 | |
#define MAX_DEP 18 | |
int N; | |
vector<int> adj[MAX_N]; | |
int depth[MAX_N]; | |
int parent[MAX_N][MAX_DEP]; // N번째 노드의 2^K번째 부모 노드 |