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 typing import List, Optional | |
# Binomial Min-Heap | |
# author: Naoki Otani (@naoppyj in GitHub) | |
# not tested yet | |
# feel free to ask me if you have any questions, or if you find any bugs | |
class BinomialHeapNode: | |
value: int |
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 "QTree.h" | |
#include <random> | |
#include <climits> | |
int BitSeparate16(int n) | |
{ | |
n = (n | (n << 8)) & 0x00ff00ff; | |
n = (n | (n << 4)) & 0x0f0f0f0f; | |
n = (n | (n << 2)) & 0x33333333; | |
n = (n | (n << 1)) & 0x55555555; |
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 numpy as np | |
arr = np.array([116, 117, 120, 120, 118, 119, 120, 97, 120, 122, 107, 55, 119, 115, 73, 36]) | |
avg = arr.mean() | |
print(f"avg : {avg}") | |
bitplane = np.zeros((16,), dtype=np.int64) | |
bitplane[arr < avg] = 0 | |
bitplane[arr >= avg] = 1 | |
print(bitplane.reshape(4, 4)) | |
H = arr[bitplane].mean() |
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
/** | |
* Trie木のノード | |
* | |
* @param previousNodeID このノードの直前のノードのID | |
* @param charSize 追加される文字のあり得る種類の数 | |
*/ | |
class TrieNode(val previousNodeID: Int?, charSize: Int) { | |
val next = IntArray(charSize) { -1 } | |
/** | |
* このノードの子供以下に追加された全ての文字列の個数 |
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 java.util.* | |
import kotlin.collections.ArrayList | |
private data class Edge(val to: Int) | |
fun main() { | |
val n = 10 | |
val edges = Array(n) { | |
ArrayList<Edge>() | |
} |
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
package algorithms.search | |
/** | |
* elementをキーとして、キー以上の要素の中で最も小さい位置のインデックスを返す。 | |
* 検索範囲は[fromIndex, toIndex) | |
* | |
* @param fromIndex この位置を含む範囲 | |
* @param toIndex この位置を含まない範囲 | |
* @return 0-indexedなインデックス | |
*/ |
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 kotlin.math.min | |
/** | |
* 参考:https://github.com/tatyam-prime/kyopro_library/blob/master/RollingHash.cpp | |
*/ | |
private val bases = | |
intArrayOf(257, 262, 266, 275, 276, 281, 285, 290, 296, 302, 306, | |
310, 311, 313, 323, 333, 344, 345, 350, 357, 367, 370, 373, | |
402, 423, 425, 431, 440, 442, 443, 454, 457, 458, 462, 471, |
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
public class UnionFind { | |
private int[] par; | |
public UnionFind(int v) { | |
for(int i = 0; i < v; i++) par[i] = i; | |
} | |
public int root(int k) { | |
if(par[k] == k) return k; | |
else return par[k] = root(par[k]); | |
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
struct cell { | |
char word[100]; | |
struct cell *next; | |
}; | |
typedef struct cell Cell; |
NewerOlder