Skip to content

Instantly share code, notes, and snippets.

肩慣らし
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0021
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0012
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0081
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1100
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0023
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0153
ライブラリを作ろう/アドホックなのもてきとーに出来るようになろう
@MiSawa
MiSawa / adj.cc
Last active August 29, 2015 14:11
#include <bits/stdc++.h>
using namespace std;
typedef complex<int> P;
struct adjacent{
P p;
adjacent(const P &p) : p(p){}
template<typename ...Args> adjacent(const Args &...args) : p(args...){}
struct Iter : public forward_iterator_tag {
#include <bits/stdc++.h>
using namespace std;
template<typename Res, typename ...Args> struct _memoized{//{{{
function<Res(Args...)> f;
map<tuple<Args...>, Res> memo;
_memoized(function<Res(Args...)> &f) : f(f){}
Res operator()(Args ...args){
const auto &key = make_tuple(args...);
@MiSawa
MiSawa / bb.cc
Last active August 29, 2015 14:16
// https://codeiq.jp/ace/kawazoe/q1339
#include <iostream>
#include <vector>
long long k_bonacci(const int &k, const int &n){
std::vector<long long> v(k, 0);
long long res = v.back() = 1;
for(int i = 0; i < n; ++i) std::swap(v[i%k] = res * 2 - v[i%k], res);
return res;
}
int main(){
@MiSawa
MiSawa / main.cc
Created June 14, 2015 17:35
template for dcj
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
#include <bits/stdc++.h>
using namespace std;
namespace KeyWordArguments{//{{{
template<typename T>
class KeyWord {//{{{
using type = T;
KeyWord(const size_t &id, const T &val) : id(id), val(val) {}
static inline size_t get_id(){ static size_t count = 0; return count++; }
public:
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
@MiSawa
MiSawa / ICPCAugRelabel.cc
Last active August 24, 2024 15:31
AugmentRelabel
using ll = long long;
// https://gist.github.com/MiSawa/2818cf0bfdb27d42c429f2adb7ee9bc0
// バグってても責任とりません >_<
// 下に行くほど最適化が減る代わりに記述が楽になります
struct ICPCAugRelabel {//{{{
using Flow = int64_t;
constexpr static Flow INF = numeric_limits<Flow>::max();
struct E{
size_t t, rev;
@MiSawa
MiSawa / ModInt.cc
Last active April 22, 2019 14:24
俺の考えた最強の ModInt. http://tokoharuland.hateblo.jp/entry/2019/04/22/004513 に感化されて書いたやつ.
#include <iostream>
#include <type_traits>
// param > 0 => use param as the modulo
// param <= 0 => you can set the modulo with ModInt<param>::set_modulo(...) in runtime.
// Of course, those runtime modulo will be distinguished if the param was different.
template<int param>
class ModInt{//{{{
using Z = int;
using N = unsigned int;
@MiSawa
MiSawa / gen.cpp
Last active October 15, 2024 15:19
Exponential instance for a wrong implementation of Dinic
#include <iostream>
#include <vector>
#include <tuple>
#include <array>
// s u - u - u - u
// | > a < X X X > c - t
// b v - v - v - v