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
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
class FordFulkerson { | |
struct edge { int from, to, cap, rev; }; | |
static const int INF = 1 << 30; |
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
template<class T, class E> | |
struct SegTree{ | |
typedef function<T(T,T)> F; | |
typedef function<T(T,E)> G; | |
typedef function<E(E,E)> H; | |
typedef function<E(E,int)> P; | |
int n; | |
F f; | |
G g; | |
H h; |
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; | |
using Key = int; | |
using Value = int; | |
struct Treap { | |
Key key; | |
Value val; | |
int pri; // priority(小さい方が上) |
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; | |
#define rep(i,n) for (int i=0;i<(n);i++) | |
#define rep2(i,a,b) for (int i=(a);i<(b);i++) | |
#define rrep(i,n) for (int i=(n)-1;i>=0;i--) | |
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--) | |
#define chmin(a,b) (a)=min((a),(b)); | |
#define chmax(a,b) (a)=max((a),(b)); | |
#define all(a) (a).begin(),(a).end() |
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
import heapq | |
def dijkstra(G, s): | |
n = len(G) | |
INF = float("inf") | |
d = [INF] * n | |
d[s] = 0 | |
pq = [] | |
heapq.heappush(pq, (0, s)) # (cost, vertex) | |
while pq: |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
from pycpx import CPlexModel | |
# 入力(有向グラフ,頂点は0-index) | |
# n m | |
# s_1 t_1 c_1 | |
# s_2 t_2 c_2 | |
# ... |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
from pycpx import CPlexModel | |
# 入力(有向グラフ,頂点は0-index) | |
# n m | |
# s_1 t_1 c_1 | |
# s_2 t_2 c_2 | |
# ... |
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; | |
#define int long long // <-----!!!!!!!!!!!!!!!!!!! | |
#define rep(i,n) for (int i=0;i<(n);i++) | |
#define rep2(i,a,b) for (int i=(a);i<(b);i++) | |
#define rrep(i,n) for (int i=(n)-1;i>=0;i--) | |
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--) | |
#define chmin(a,b) (a)=min((a),(b)); | |
#define chmax(a,b) (a)=max((a),(b)); |
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
using Vertex = tuple<int, int, int>; // {i, j, k} | |
using State = pair<int, Vertex>; | |
priority_queue<State, vector<State>, greater<State>> pq; // cost, vertex | |
vvvi d(n, vvi(c + 1, vi(2, inf))); | |
d[0][v0][0] = 0; | |
pq.push(State(0, make_tuple(0, v0, 0))); | |
while (!pq.empty()) { | |
int cost; | |
Vertex vertex; |
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; | |
#define int long long // <-----!!!!!!!!!!!!!!!!!!! | |
#define rep(i,n) for (int i=0;i<(n);i++) | |
#define rep2(i,a,b) for (int i=(a);i<(b);i++) | |
#define rrep(i,n) for (int i=(n)-1;i>=0;i--) | |
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--) | |
#define chmin(a,b) (a)=min((a),(b)); | |
#define chmax(a,b) (a)=max((a),(b)); |
NewerOlder