Skip to content

Instantly share code, notes, and snippets.

View buyoh's full-sized avatar
☪️

mai buyoh

☪️
View GitHub Profile
# begin input
N = 100000
K = 100
arr = Array.new(N){rand(0..(K*2))}
p arr
# end input
@buyoh
buyoh / detect_edge.cpp
Created March 30, 2018 09:28
bmp.境界検出難しいね
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define debug(v) {printf("L%d %s > ",__LINE__,#v);cout<<(v)<<endl;}
#define debugv(v) {printf("L%d %s > ",__LINE__,#v);for(auto e:(v)){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) {printf("L%d %s > ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;}
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include "bits/stdc++.h" // define macro "/D__MAI"
using namespace std;
typedef long long int ll;
#define debug(v) {printf("L%d %s > ",__LINE__,#v);cout<<(v)<<endl;}
#define debugv(v) {printf("L%d %s > ",__LINE__,#v);for(auto e:(v)){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) {printf("L%d %s > ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;}
@buyoh
buyoh / testcases.rb
Created June 29, 2017 16:29
毎回このコードを書いてる気がする
require 'fileutils'
fileinfo = [["0test",5],["1simple",10],["5extreme",10]]
fileinfo.each{|name,count|
count.times{|index|
FileUtils.touch(sprintf("%s%02d.txt",name,index))
}
}
module BWT
module_function
def convert(str)
(0...str.size).to_a.sort!{|l,r| str[l..-1] <=> str[r..-1]}.map!{|e| str[e-1]}*""
end
def convert_i(str)
idxlist = (0...str.size).to_a.sort!{|l,r| str[l..-1] <=> str[r..-1]}
head = idxlist.index(0)
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include "bits/stdc++.h" // define macro "/D__MAI"
using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
@buyoh
buyoh / codeiq_cword.rb
Last active April 7, 2017 13:55
クロッシング・ワード
# https://codeiq.jp/q/2841
#
# 方針:(n>=2)
#
# 各列のパターンは次の5つのいずれか.
# 0.___ 1.#__ 2._#_ 3.__# 4.#_#
#
# i列目にそのパターンが配置できるかどうか判定するには,i-1,i-2列目の情報が必要.
# 愚直に再帰を使って実装すると,gchokuメソッドのようになる.TLE.
#
@buyoh
buyoh / solveVertexCover.cpp
Created March 30, 2017 23:56
minimum vertex cover problem (最小頂点被覆問題,近似アルゴリズム,焼きなましアルゴリズム(焼きなまし法とは異なります))
/*
最小頂点被覆の近似解を求める.
初めに線形時間で終わる2倍近似アルゴリズムを走らせ,そのあと,焼きなましで改善する.
*/
#include "bits/stdc++.h"
using namespace std;
#define TIME std::chrono::system_clock::now()
@buyoh
buyoh / blog20170103.cpp
Last active January 9, 2017 01:41
本来書きたかったコードと間違ったコード.コンパイルも通り,セグメンテーション違反も無い.
#include<bits/stdc++.h>
using namespace std;
struct Hoge{
int a,b,c;
Hoge(int a=0,int b=0,int c=0):a(a),b(b),c(c){}
};
int main(){
vector<int> mat;
@buyoh
buyoh / bf.cpp
Created November 28, 2016 16:45
brainfuckインタプリタ仮置き
#include<bits/stdc++.h>
using namespace std;
template<size_t buffer_size = 1024>
class Brainfucker{
public:
string code;
string input;
string output;