Skip to content

Instantly share code, notes, and snippets.

@fushime2
fushime2 / rpn.d
Last active October 9, 2018 04:42
class RPNCalculator {
import std.algorithm : all, canFind, map;
import std.ascii : isDigit, isWhite;
import std.conv : to;
import std.string : split;
import std.range;
alias Stack = int[];
bool isNum(const char[] cs) {
return cs.all!(c => isDigit(c));
// cとみせかけてc++の文法を使う可能性もある
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define N 6
@fushime2
fushime2 / bipartite_matching.d
Last active April 16, 2018 04:49
Calculate bipartite matching by using Ford-Fulkerson algorithm
// 二部マッチング
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A
// https://beta.atcoder.jp/contests/abc091/tasks/arc092_a
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
void main() {
auto bm = new BipartiteMatching();
int X, Y, E;
readf("%d %d %d\n", &X, &Y, &E);
//
// $ dmd margesort.d -main -unittest
//
import std.stdio;
T[] margesort(T)(T[] a) {
int n = a.length;
if (n <= 1) return a;
T[] left = a[0..n/2].margesort;
@fushime2
fushime2 / 0retweet.py
Last active August 25, 2017 07:34
TweetIDを指定してReTweetする
#
# ツイートは 2014/04/01 まで取得済み
#
import tweepy
import random
import time
def get_api():
@fushime2
fushime2 / LCA.cpp
Last active March 28, 2017 04:28
Lowest Common Ancestor
struct LCA {
typedef vector<vector<int>> Graph;
Graph G;
vector<int> depth;
vector<vector<int>> parent;
int n, root, MAXLOG;
LCA(int _n) {
root = 0;
n = _n;
@fushime2
fushime2 / shadow.cpp
Last active April 13, 2018 06:54
家に影をつける
//
// 家に影を付ける
//
#include <cstdlib>
#include <cmath>
#include "GL/glut.h"
using namespace std;
@fushime2
fushime2 / color.cpp
Last active April 30, 2017 00:45
Color House
#include <cstdio>
#include <cstdlib>
#include "GL/glut.h"
using namespace std;
// 直方体の表面
int face[][4] = {
{0, 3, 2, 1},
{1, 2, 6, 5},
@fushime2
fushime2 / daia.cpp
Created November 13, 2016 18:53
OpenGLでトランプのダイヤの3を表示
//
// トランプのダイヤの3を作成する。
// ポリゴン1,2,3を作り、ポリゴン1,3をそれぞれy軸側に-0.5, +0.5 移動させる。
// 全体を45度回転させる。
//
#include <cstdlib>
#include <cstdio>
#include "GL/glut.h"