This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace template_algorithm { | |
template<typename flow_T, typename cost_T> | |
class primal_dual { | |
//辺クラス | |
private: class edge { | |
public: | |
int to; | |
flow_T cap; | |
cost_T cost; | |
int rev; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
namespace template_algorithm { | |
template<typename T> | |
class lazy_segment_tree { | |
public: | |
lazy_segment_tree(vector<T> &vec, T e_, T lazy_e_, function<T(T, T)> mapping_, | |
function<T(T, T)> operation_, function<T(T, T)> composition_, function<T(T, int)> multiplier_) | |
: e(e_), lazy_e(lazy_e_), mapping(mapping_), operation(operation_), composition(composition_), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
namespace template_algorithm { | |
/*辺情報*/ | |
template<typename T> | |
struct edge { | |
//rev := to(辺の終点)の隣接リストでの辺の始点へ向かう逆辺の番号 | |
int rev; | |
int to; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
namespace template_algorithm { | |
template<typename T> | |
class segment_tree { | |
public: | |
/// @brief n_個に合わせてツリーを作り、値を単位元で埋めるコンストラクタ1 | |
/// @param n_ 区間サイズ | |
/// @param e_ 単位元 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace template_algorithm { | |
/// @brief ダイクストラ法(クラス) | |
/// @attention 求められるものは「startからの」最短経路。 求める際は0-indexedにすること。 | |
template<typename T> | |
class dijkstra{ | |
public: | |
/// @brief 辺クラス | |
class edge{ | |
public: | |
int to; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
namespace template_algorithm { | |
template<typename T> | |
class binary_search { | |
public: | |
//コンストラクタ | |
binary_search(bool is_maximize_, function<bool(T)> fn_) | |
: is_maximize(is_maximize_), is_ok(fn_) {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
/// @brief 辺のクラス: 比較は辺の重みでしたいとする | |
/// @tparam T コストなどの型 | |
template<typename T> | |
class edge{ | |
public: | |
T to; | |
T cost; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
//比較関数だよ: lの優先順位が低い時にtrueを返すらしいよ | |
auto compare = [](int l, int r) { return abs(l) < abs(r); }; | |
//「decltype(比較関数)」と「変数名(比較関数)」が増えたよ | |
priority_queue<int, vector<int>, decltype(compare)> pq(compare); | |
//今回は絶対値が大きい順にソートされて出てくるよ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
/*数独ソルバー | |
使い方:step1 | |
まず表に最初から埋まっている数を一行ごとに入力していきます | |
空いているマスは0で表します | |
step2 | |
コードを実行する | |
*/ |