Skip to content

Instantly share code, notes, and snippets.

View knuu's full-sized avatar

knuu knuu

View GitHub Profile
@knuu
knuu / main.rs
Last active October 1, 2023 12:30
rust 本 5 章
use std::{collections::HashMap, vec};
type Table = HashMap<String, Vec<String>>;
fn show(table: &Table) {
for (artist, works) in table {
println!("works by {}:", artist);
for work in works {
println!(" {}", work);
}
}
@knuu
knuu / exec.py
Last active July 10, 2023 03:28
Code Interpreter に含まれる module
# 実行されたコード
import pkgutil
# List all available modules
available_modules = [module.name for module in pkgutil.iter_modules()]
available_modules
@knuu
knuu / lightgbm-learning-to-rank.ipynb
Last active January 8, 2023 14:21
LightGBM でかんたん Learning to Rank
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knuu
knuu / MakingRegularGraph.cpp
Created June 2, 2018 18:56
TCO Round2 Med MakingRegularGraph
struct MakingRegularGraph {
int n;
vector<int> x, y, deg;
set<int> rest;
set<pair<int, int>> edge;
void dfs(vector<int> &ans) {
if (rest.size() == 0) {
return ;
} else if (rest.size() == 1) {
@knuu
knuu / heap.c
Created May 16, 2018 14:18
Heap by C
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "heap.h"
Heap *initHeap(int maxSize) {
Heap *h = malloc(sizeof(Heap));
if (h == NULL) {
return NULL;
@knuu
knuu / exe_2_6.c
Created April 15, 2018 16:04
k&r exercise
#include <stdio.h>
#include <limits.h>
unsigned int getbits(unsigned int x, int p, int n);
unsigned int setbits(unsigned int x, int p, int n, unsigned int y);
void print_bits(unsigned int x);
int main() {
print_bits(setbits((1 << 5) - 1, 3, 3, 10)); // x = 11111, y = 1010 => 10101
@knuu
knuu / mex_query.cpp
Created February 24, 2018 10:52
range mex query problem
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())
const int INF = INT_MAX;
@knuu
knuu / ctf_h.cpp
Created December 10, 2017 12:16
CODE THANKS FESTIVAL 2017 H. Union Sets
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
struct DisjointSet {
vector<int> parent, rank;
DisjointSet(int N) {
@knuu
knuu / rank_cf2017_qb
Created October 8, 2017 16:39
CODE FESTIVAL 2017 予選B
# 予選Aで日本人60位までが通過したという情報を元にしたランキング
# 日本人順位(全体順位): ハンドルネーム
# 通過済みの日本人順位は--としている
--(4): yutaka1999
--(22): tozangezan
--(23): mcfx
1(24): DEGwer
2(32): yokozuna57
3(33): sugim48
--(34): kmjp
@knuu
knuu / arc075_c.nim
Created August 3, 2017 14:03
AtCoder Regular Contest 075 E. Meaningful Mean
import sequtils, strutils, algorithm
type
FenwickTree[T] = object
dat: seq[T]
size: int
initial: T
proc initFenwickTree[T](size: int, initial: T): FenwickTree[T] =
assert(size > 0)