Skip to content

Instantly share code, notes, and snippets.

@MiSawa
MiSawa / heap.rs
Created March 5, 2024 14:52
MinHeap and MaxHeap
#!/usr/bin/env rust-script
use std::{
cmp::{Ord, Ordering},
collections::BinaryHeap,
ops::{Deref, DerefMut},
};
pub trait Priority<T: ?Sized> {
fn eq(lhs: &T, rhs: &T) -> bool {
@MiSawa
MiSawa / generate_rust_project.rs
Created April 15, 2023 16:10
Generate rust-project.json for rust-script
#!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! clap = { version = "4.1.8", features = ["derive"] }
//! eyre = "0.6.8"
//! path-absolutize = "3.0.14"
//! serde = { version = "1.0.156", features = ["derive"] }
//! serde_json = "1.0.95"
//!
//! paths = { git = "https://github.com/rust-lang/rust-analyzer.git", tag = "2023-04-10" }
@MiSawa
MiSawa / keybase.md
Created November 18, 2022 09:11
Keybase proof

Keybase proof

I hereby claim:

  • I am misawa on github.
  • I am misawa (https://keybase.io/misawa) on keybase.
  • I have a public key whose fingerprint is D5A3 7798 FFE8 F754 5B83 C133 BFFF 4B86 A074 F3D0

To claim this, I am signing this object:

@MiSawa
MiSawa / main.rs
Created March 27, 2022 15:38
Trying something for `--stream`
use std::sync::mpsc::{sync_channel, SyncSender};
use anyhow::{anyhow, Result};
#[derive(Clone, Debug)]
enum Index {
Array(usize),
Map(String),
}
type Path = Vec<Index>;
@MiSawa
MiSawa / dinic_worst.cc
Created April 24, 2021 05:33
Dinic worst case behavior
#include <algorithm>
#include <cassert>
#include <limits>
#include <queue>
#include <vector>
#include <vector>
namespace atcoder {
@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
@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 / 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;
#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: