<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/procom/">
    <title>procom @ ウィキ</title>
    <link>http://w.atwiki.jp/procom/</link>
    <atom:link href="https://w.atwiki.jp/procom/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>procom @ ウィキ</description>

    <dc:language>ja</dc:language>
    <dc:date>2014-04-11T23:12:32+09:00</dc:date>
    <utime>1397225552</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/2.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/16.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/15.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/14.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/13.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/8.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/12.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/11.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/10.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/9.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/procom/pages/2.html">
    <title>メニュー</title>
    <link>https://w.atwiki.jp/procom/pages/2.html</link>
    <description>
      
&lt;h3 id=&quot;id_b7a6c500&quot;&gt;メニュー&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;&lt;a title=&quot;トップページ (22d)&quot; href=&quot;http://www57.atwiki.jp/procom/pages/1.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;トップページ&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/5.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;math&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/6.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;sort&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/7.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;comparator&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/8.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;string&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/9.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;data structure&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/10.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;shortest path&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/11.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;minimum spanning tree&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/12.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;search&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/13.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;max flow&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/14.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;minimum cost flow&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/16.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;geometry&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/pages/15.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;others&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h3 id=&quot;id_453df200&quot;&gt;リンク&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://atwiki.jp/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;@wiki&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://atwiki.jp/guide/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;@wikiご利用ガイド&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h3 id=&quot;id_c0085a49&quot;&gt;他のサービス&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://atpages.jp/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;無料ホームページ作成&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://atword.jp/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;無料ブログ作成&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://atchs.jp/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;2ch型掲示板レンタル&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://atbbs.jp/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;無料掲示板レンタル&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://atpaint.jp/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;お絵かきレンタル&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://sns.atfb.jp/&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;無料ソーシャルプロフ&lt;/font&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www1.atwiki.jp/wpmode_guide&quot;&gt;wikiの編集方法についてはこちら&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www1.atwiki.jp/wpmode_guide/pages/25.html&quot;&gt;左メニューの編集方法についてはこちら&lt;/a&gt;&lt;br /&gt;
 &lt;/p&gt;
&lt;div&gt;&lt;a href=&quot;http://www57.atwiki.jp/procom/editx/2.html&quot;&gt;&lt;font color=&quot;#5F441A&quot;&gt;ここを編集&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;
    </description>
    <dc:date>2014-04-11T23:12:32+09:00</dc:date>
    <utime>1397225552</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/16.html">
    <title>geometry</title>
    <link>https://w.atwiki.jp/procom/pages/16.html</link>
    <description>
      -点クラス　複素平面をイメージ
#highlight(java){{
class P{
	static final double EPS=1e-10;
	static int signum(double x){
		return x&lt;-EPS?-1:x&gt;EPS?1:0;
	}
	static Comparator&lt;P&gt; comp = new Comparator&lt;P&gt;(){
		public int compare(P p1, P p2) {
			return signum(p1.x-p2.x)!=0?signum(p1.x-p2.x):signum(p1.y-p2.y);
		}
	};
	public static final P O = new P(0,0);
	final double x, y;
	P(double _x,double _y){
		x=_x;
		y=_y;
	}
	//四則
	P add(P a){
		return new P(x+a.x,y+a.y);
	}
	P sub(P a){
		return new P(x-a.x,y-a.y);
	}
	P mul(P a){
		return new P(x*a.x-y*a.y,x*a.y+y*a.x);
	}
	P div(P a){
		double d2=a.dist2(O);
		return new P(dot(a,this)/d2,cross(a,this)/d2);
	}
	//共役
	P conj(){
		return new P(x,-y);
	}
	//内積　a・b=|a||b|cosθ=a.x*b.x+a.y*b.y
	static double dot(P a,P b){
		return  a.x*b.x+a.y*b.y;
	}
	//外積　a×b=|a||b|sinθ=a.x*b.y-a.y*b.x
	static double cross(P a,P b){
		return  a.x*b.y-a.y*b.x;
	}
	//二乗距離
	double dist2(P p){
		return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y);
	}
	//a,b間の距離
	double dist(P p){
		return sqrt(dist2(p));
	}
	public double norm(){
		return dist(O);
	}
	// a→b→cと進むときの向き
	static int ccw(P a,P b,P c){
		b = b.sub(a); c = c.sub(a);
		if(cross(b,c)&gt;EPS) return 1;//counter clockwise
		if(cross(b,c)&lt;-EPS) return -1;//clockwise
		if(dot(b,c)&lt;-EPS) return 2;//c--a--b on line
		if(b.norm()&lt;c.norm()-EPS) return -2;//a--b--c on line
		return 0;//a--c--b on line (or b==c)
	}
	//oからみたaの角度
	static double arg(P a,P o){
		P dir=a.sub(o);
		double s=acos(dir.x/dir.norm());
		return dir.y&gt;0?s:2*PI-s;
	}
	//oを中心に回転
	P rotate(P o,double arg){
		return this.add(this.sub(o).mul(new P(cos(arg),sin(arg))));
	}
	//→OA,→OBの面積の2倍
	static double S2(P a,P b,P o){
		return cross(a.sub(o),b.sub(o));
	}
	static double S(P a,P b,P o){
		return S2(a,b,o)/2;
	}
	//絶対値と偏角から座標を取得
	static P polar(double abs,double arg){
		return new P(abs*cos(arg),abs*sin(arg));
	}
	// ?
	static P proj(P p,P o){
		return o.mul(new P(dot(p,o)/o.norm(),0));
	}
	public boolean equals(Object obj) {
		if(obj instanceof P){
			P p=(P)obj;
			return signum(x-p.x)==0 &amp;&amp; signum(y-p.y)==0;
		}
		return false;
	}
	
	public String toString(){
		return &quot;(&quot;+x+&quot;,&quot;+y+&quot;)&quot;;
	}
}
}}
-線クラス
#highlight(java){{
//(注)
//dist,isIntersectは擬似的に二項関係の演算子として扱う
//intersectionはPのコンストラクタとして扱う
class L extends AL{
	L(P _p1, P _p2) {super(_p1, _p2);}

	//直線と点の距離
	double dist(P p){
		return abs(P.S(p2,p,p1))/p1.sub(p2).norm();
	}
	boolean isIntersect(P p){
		return abs(P.S(p2,p,p1))&lt;EPS;
	}
	boolean isIntersect(L l){
		if(isPoint() &amp;&amp; l.isPoint())return p1.equals(l.p1);
		if(isPoint())return l.isIntersect(p1);
		if(l.isPoint())return isIntersect(l.p1);
		return !isParallel(l) || isIntersect(l.p1);
	}

	//垂線の足
	static P FootOfLP(L l,P p){
		return l.p1.add(P.proj(p.sub(l.p1),l.p2.sub(l.p1)));
	}

	//線対称な点
	static P LineSymmetricLP(L l,P p){
		return FootOfLP(l,p).mul(new P(2.0,0)).sub(p);
	}

	public boolean equals(Object obj) {
		if(obj instanceof L){
			L l=(L)obj;
			return isParallel(l) &amp;&amp; isIntersect(l.p1);
		}
		return false;
	}
}
//線分
class S extends AL{
	S(P _p1, P _p2) {super(_p1, _p2);}
	boolean isIntersect(P p){//|a-p|+|p-b|&lt;=|a-b|
		return p1.sub(p).norm()+p2.sub(p).norm()&lt;=p1.sub(p2).norm()+EPS;
	}
	boolean isIntersect(L l){//l2の端点がl1の上か下か
		return P.cross(l.p2.sub(l.p1),p1.sub(l.p1))*
			P.cross(l.p2.sub(l.p1),p2.sub(l.p1))&lt;EPS;
	}
	boolean isIntersect(S l){
		return P.ccw(p1,p2,l.p1)*P.ccw(p1,p2,l.p2)&lt;=0
		&amp;&amp; P.ccw(l.p1,l.p2,p1)*P.ccw(l.p1,l.p2,p2)&lt;=0;
	}
	//線分と点
	double dist(P p){
		if(P.dot(p2.sub(p1),p.sub(p1))&lt;EPS)return p.sub(p1).norm();
		if(P.dot(p1.sub(p2),p.sub(p2))&lt;EPS)return p.sub(p2).norm();
		return abs(P.S(p2,p,p1))/p1.sub(p2).norm();
	}
	//直線との距離
	double dist(L l){
		if(isIntersect(l))return 0;
		return min(l.dist(p1),l.dist(p2));
	}
	//線分と線分
	double dist(S l){
		if(isIntersect(l))return 0;
		return min(min(dist(l.p1),dist(l.p2)),min(l.dist(p1),l.dist(p2)));
	}
}
abstract class AL{
	//geo
	static final double EPS=1e-10;
	static int signum(double x){
		return x&lt;-EPS?-1:x&gt;EPS?1:0;
	}
	public P p1,p2;
	AL(P _p1,P _p2){
		p1=_p1;
		p2=_p2;
	}

	boolean isPoint(){
		return p1.equals(p2);
	}

//	public double a(){
//		P dir= p2.sub(p1);
//		return dir.y/dir.x;
//	}
//	public double b(){
//		return P.cross(p1,p2)/(p1.x-p2.x);
//	}

	//平行
	boolean isParallel(AL l){
		return abs(P.cross(p2.sub(p1),l.p2.sub(l.p1)))&lt;EPS;
	}
	//直交
	boolean isOrthogonal(AL l){
		return abs(P.dot(p2.sub(p1),l.p2.sub(l.p1)))&lt;EPS;
	}

	//交点 (交差判定なし)
	static P intersection(AL l1,AL l2){
		P dl1=l1.p2.sub(l1.p1),dl2=l2.p2.sub(l2.p1);
		double a=P.cross(dl2,l2.p1.sub(l1.p1));
		double b=P.cross(dl2,dl1);
		if(abs(a)&lt;EPS &amp;&amp; abs(b) &lt;EPS)return l1.p1;//same
		return l1.p1.add(dl1.mul(new P(a/b,0.0)));
	}


	public boolean equals(Object obj) {
		if(obj instanceof L){
			L l=(L)obj;
			return this.p1.equals(l.p1) &amp;&amp; this.p2.equals(l.p2);
		}
		return false;
	}
	public String toString(){
		return p1+&quot;-&quot;+p2;
	}
}
}}    </description>
    <dc:date>2014-04-11T23:11:53+09:00</dc:date>
    <utime>1397225513</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/15.html">
    <title>others</title>
    <link>https://w.atwiki.jp/procom/pages/15.html</link>
    <description>
      -next_permutation
#highlight(java){{
static boolean next_permutation(int[]as) {
	int n = as.length;
	for (int i = n - 1; i &gt; 0; i--) {
		if (as[i - 1] &lt; as[i]) {
			int j = n;
			while (as[i - 1] &gt;= as[--j]);
			swap(as, i - 1, j);
			reverse(as, i, n);
			return true;
		}
	}
	return false;
}
static void swap(int[] is, int i, int j) {
	int t = is[i];
	is[i] = is[j];
	is[j] = t;
}
static void reverse(int[] is, int s, int t) {
	while (s &lt; --t) swap(is, s++, t);
}
}}    </description>
    <dc:date>2014-04-10T23:21:36+09:00</dc:date>
    <utime>1397139696</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/14.html">
    <title>minimum cost flow</title>
    <link>https://w.atwiki.jp/procom/pages/14.html</link>
    <description>
      -辺クラス
#highlight(java){{
class Edge {
	int to, cap, cost, rev;
	Edge(int to, int cap, int cost, int rev) {
		this.to = to;
		this.cap = cap;
		this.cost = cost;
		this.rev = rev;
	}
}
}}

-最小費用流(Bellman-Ford)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
List&lt;Edge&gt;[] list;
int[] d;
int[] prevv, preve;

void addEdge(int from, int to, int cap, int cost) {
	list[from].add(new Edge(to, cap, cost,list[to].size()));
	list[to].add(new Edge(from, 0, -cost, list[from].size()-1));
}

int min_cost_flow(int s, int t , int f) {
	int n = list.length;
	d = new int[n];
	prevv = new int[n]; preve = new int[n];
	int res = 0;
	while (f &gt; 0) {
		Arrays.fill(d, INF);
		d[s] = 0;
		boolean update = true;
		while (update) {
			update = false;
			for (int v = 0; v &lt; n; v++) {
				if (d[v] == INF) continue;
				for (int i = 0; i &lt; list[v].size(); i++) {
					Edge e = list[v].get(i);
					if (e.cap &gt; 0 &amp;&amp; d[e.to] &gt; d[v] + e.cost) {
						d[e.to] = d[v] + e.cost;
						prevv[e.to] = v;
						preve[e.to] = i;
						update = true;
					}
				}
			}
		}
	
		if (d[t] == INF) return -1;
		
		int c = f;
		for (int v = t; v != s; v = prevv[v]) {
			c = Math.min(c, list[prevv[v]].get(preve[v]).cap);
		}
		f -= c;
		res += c * d[t];
		for (int v = t; v != s; v = prevv[v]) {
			Edge e = list[prevv[v]].get(preve[v]);
			e.cap -= c;
			list[v].get(e.rev).cap += c;
		}
	}
	
	return res;
}
}}    </description>
    <dc:date>2013-11-22T23:24:55+09:00</dc:date>
    <utime>1385130295</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/13.html">
    <title>max flow</title>
    <link>https://w.atwiki.jp/procom/pages/13.html</link>
    <description>
      -辺クラス
#highlight(java){{
class Edge {
	int to;
	int cap;
	int rev;
	Edge(int to, int cost, int rev) {
		this.to = to;
		this.cap = cost;
		this.rev = rev;
	}
}
}}

-Ford-Fulkerson法(隣接リスト)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
List&lt;Edge&gt;[] list;
boolean[] used;

void addEdge(int from, int to, int cap) {
	list[from].add(new Edge(to, cap,list[to].size()));
	list[to].add(new Edge(from, 0, list[from].size()-1));
}

int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i &lt; list[v].size(); i++) {
		Edge e = list[v].get(i);
		if (!used[e.to] &amp;&amp; e.cap &gt; 0) {
			int d = dfs(e.to, t, Math.min(f, e.cap));
			if (d &gt; 0) {
				e.cap -= d;
				list[e.to].get(e.rev).cap += d;
				return d;
			}
		}
	}
	return 0;
}

int ford_fulkerson(int s, int t) {
	int flow = 0;
	while (true) {
		Arrays.fill(used, false);
		int f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}
}}    </description>
    <dc:date>2013-11-22T18:31:42+09:00</dc:date>
    <utime>1385112702</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/8.html">
    <title>string</title>
    <link>https://w.atwiki.jp/procom/pages/8.html</link>
    <description>
      -反転
#highlight(java){{
String reverse(String s) {
	String ans = &quot;&quot;;
	int len = s.length();
	for (int i = 0; i &lt; len; i++)
		ans += s.charAt(len-i-1);
	return ans;
}
}}
-回文判定~
空文字列&quot;&quot;もtrueを返す
#highlight(java){{
boolean isPalindrome(String s) {
	int i = 0, j = s.length()-1;
	while (i &lt; j) {
		if (s.charAt(i) != s.charAt(j)) return false;
		i++;
		j--;
	}
	return true;
}
}}    </description>
    <dc:date>2013-11-11T00:38:34+09:00</dc:date>
    <utime>1384097914</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/12.html">
    <title>search</title>
    <link>https://w.atwiki.jp/procom/pages/12.html</link>
    <description>
      -lower_bound~
key以上の値が出現する最初のインデックスを返す
#highlight(java){{
int lower_bound(int[] a, int key) {
	int lb = 0, ub = a.length-1;
	if (a[lb] == key) return lb; 
	while (ub - lb &gt; 1) {
		int mid = (ub + lb) / 2;
		if (a[mid] &gt;= key)
			ub = mid;
		else
			lb = mid;
	}
	return ub;
}
}}


-upper_bound~
keyより大きい値が出現する最初のインデックスを返す
#highlight(java){{
int upper_bound(int[] a, int key) {
	int lb = 0, ub = a.length-1;
	if (a[ub] == key) return ub + 1;
	while (ub - lb &gt; 1) {
		int mid = (ub + lb) / 2;
		if (a[mid] &gt; key)
			ub = mid;
		else
			lb = mid;
	}
	return lb+1;
}
}}    </description>
    <dc:date>2013-10-26T13:01:27+09:00</dc:date>
    <utime>1382760087</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/11.html">
    <title>minimum spanning tree</title>
    <link>https://w.atwiki.jp/procom/pages/11.html</link>
    <description>
      -Prim法(隣接行列)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
int[][] cost;

int prim() {
	int n = cost.length;
	int[] mincost = new int[n];
	boolean[] used = new boolean[n];
	Arrays.fill(mincost, INF);
	
	mincost[0] = 0;
	int res = 0;
	
	while (true) {
		int v = -1;
		for (int u = 0; u &lt; n; u++) {
			if (!used[u] &amp;&amp; (v == -1 || mincost[u] &lt; mincost[v]))
				v = u;
		}
		
		if (v == -1) break;
		used[v] = true;
		res += mincost[v];
		
		for (int u = 0; u &lt; n; u++) {
			mincost[u] = Math.min(mincost[u], cost[v][u]);
		}
	}
	
	return res;
}
}}


-Prim法(隣接リスト)
#highlight(java){{
class Edge {
	int to;
	int cost;
	Edge(int to, int cost) {
		this.to = to;
		this.cost = cost;
	}
}

class Pair implements Comparable&lt;Pair&gt; {
	int index;
	int cost;
	Pair(int i, int c) {
		index = i;
		cost = c;
	}
	@Override
	public int compareTo(Pair o) {
		return cost - o.cost;
	}
}

final int INF = Integer.MAX_VALUE/2;
List&lt;Edge&gt;[] list;

int prim() {
	int n = list.length;
	int[] mincost = new int[n];
	Arrays.fill(mincost, INF);
	mincost[0] = 0;
	Queue&lt;Pair&gt; queue = new PriorityQueue&lt;Pair&gt;();
	queue.add(new Pair(0, 0));
	int res = 0;
	
	while (!queue.isEmpty()) {
		Pair p = queue.poll();
		int v = p.index, c = p.cost;
		if (mincost[v] &lt; c) continue;
		res += mincost[v];
		for (Edge e : list[v]) {
			if (mincost[e.to] &gt; e.cost) {
				mincost[e.to] = e.cost;
				queue.add(new Pair(e.to, e.cost));
			}
		}
	}
	
	return res;
}
}}

-Kruskal法
#highlight(java){{
class Edge implements Comparable&lt;Edge&gt; {
	int from;
	int to;
	int cost;
	Edge(int from, int to, int cost) {
		this.from = from;
		this.to = to;
		this.cost = cost;
	}
	@Override
	public int compareTo(Edge o) {
		return cost - o.cost;
	}
}

Edge[] edge;
int n;  //頂点数

int kruskal() {
	Arrays.sort(edge);
	UnionFind uf = new UnionFind(n);
	int res = 0;
	for (int i = 0; i &lt; edge.length; i++) {
		Edge e = edge[i];
		if (!uf.same(e.from, e.to)) {
			uf.unite(e.from, e.to);
			res += e.cost;
		}
	}
	return res;
}
}}    </description>
    <dc:date>2013-10-09T11:51:29+09:00</dc:date>
    <utime>1381287089</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/10.html">
    <title>shortest path</title>
    <link>https://w.atwiki.jp/procom/pages/10.html</link>
    <description>
      -Bellman-Ford法(隣接行列)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
int[][] cost;
int[] d;

void bellman_ford(int s) {
	int n = cost.length;
	d = new int[n];
	for (int i = 0; i &lt; d.length; i++)
		d[i] = INF;
	d[s] = 0;
	boolean update;
	while (true) {
		update = false;
		for (int i = 0; i &lt; n; i++) {
			for (int j = 0; j &lt; n; j++) {
				if (cost[i][j] != INF) {
					if (d[i] != INF &amp;&amp; d[i] + cost[i][j] &lt; d[j]) {
						d[j] = d[i] + cost[i][j];
						update = true;
					}
				}
			}
		}
		if (!update) break;
	}
}
}}

-Dijkstra法(隣接行列)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
int[][] cost;
int[] d;

void dijkstra(int s) {
	int n = cost.length;
	d = new int[n];
	boolean[] used = new boolean[n];
	Arrays.fill(d, INF);
	d[s] = 0;
	
	while (true) {
		int v = -1;
		for (int u = 0; u &lt; n; u++) {
			if (!used[u] &amp;&amp; (v == -1 || d[u] &lt; d[v])) v = u;
		}
		
		if (v == -1) break;
		used[v] = true;
		
		for (int u = 0; u &lt; n; u++) {
			d[u] = Math.min(d[u], d[v]+cost[v][u]);
		}
	}
}
}}

-Warshall-Floyd法(隣接行列)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
int[][] cost;
int[][] d;

void warshall_floyd() {
	int n = cost.length;
	d = new int[n][n];
	for (int i = 0; i &lt; n; i++)
		for (int j = 0; j &lt; n; j++)
			d[i][j] = cost[i][j];
	for (int i = 0; i &lt; n; i++)
		d[i][i] = 0;
	
	for (int k = 0; k &lt; n; k++)
		for (int i = 0; i &lt; n; i++)
			for (int j = 0; j &lt; n; j++)
				d[i][j] = Math.min(d[i][j], d[i][k]+d[k][j]);
}
}}

-辺クラス
#highlight(java){{
class Edge {
	int to;
	int cost;
	Edge(int to, int cost) {
		this.to = to;
		this.cost = cost;
	}
}
}}

-Bellman-Ford法(隣接リスト)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
List&lt;Edge&gt;[] list;
int[] d;

void bellman_ford(int s) {
	int n = list.length;
	d = new int[n];
	Arrays.fill(d, INF);
	d[s] = 0;
	boolean update;
	while (true) {
		update = false;
		for (int i = 0; i &lt; n; i++) {
			for (Edge e : list[i]) {
				if (d[i] != INF &amp;&amp; d[i] + e.cost &lt; d[e.to]) {
					d[e.to] = d[i] + e.cost;
					update = true;
				}
			}
		}
		if (!update) break;
	}
}
}}

-Dijkstra法(隣接リスト)
#highlight(java){{
class Pair implements Comparable&lt;Pair&gt; {
	int index;
	int distance;
	Pair(int i, int d) {
		index = i;
		distance = d;
	}
	@Override
	public int compareTo(Pair o) {
		return distance - o.distance;
	}
	
}

final int INF = Integer.MAX_VALUE/2;
List&lt;Edge&gt;[] list;
int[] d;

void dijkstra(int s) {
	int n = list.length;
	d = new int[n];
	Arrays.fill(d, INF);
	d[s] = 0;
	Queue&lt;Pair&gt; queue = new PriorityQueue&lt;Pair&gt;();
	queue.add(new Pair(s, 0));
	
	while (!queue.isEmpty()) {
		Pair p = queue.poll();
		int v = p.index, dis = p.distance;
		if (d[v] &lt; dis) continue;
		for (Edge e : list[v]) {
			if (d[v] + e.cost &lt; d[e.to]) {
				d[e.to] = d[v] + e.cost;
				queue.add(new Pair(e.to, d[e.to]));
			}
		}
	}
}
}}

-負の閉路がある場合はtrueを返す(隣接リスト)
#highlight(java){{
List&lt;Edge&gt;[] list;
int[] d;

boolean find_negative_loop() {
	int n = list.length;
	d = new int[n];
	for (int i = 0; i &lt; n; i++) {
		for (int j = 0; j &lt; n; j++) {
			for (Edge e : list[j]) {
				if (d[j] + e.cost &lt; d[e.to]) {
					d[e.to] = d[j] + e.cost;
					
					if (i == n-1) return true;
				}
			}
		}
	}
	return false;
}
}}

-負の閉路がある場合はtrueを返す(隣接行列)
#highlight(java){{
final int INF = Integer.MAX_VALUE/2;
int[][] cost;
int[] d;

boolean find_negative_loop() {
	int n = cost.length;
	d = new int[n];
	for (int i = 0; i &lt; n; i++) {
		for (int j = 0; j &lt; n; j++) {
			for (int k = 0; k &lt; n; k++) {
				if (cost[j][k] != INF) {
					if (d[j] + cost[j][k] &lt; d[k]) {
						d[k] = d[j] + cost[j][k];
						
						if (i == n-1) return true;
					}
				}
			}
		}
	}
	return false;
}
}}

-経路復元(Dijkstra)
#highlight(java){{
int[][] cost;
int[] d;
int[] prev;

void dijkstra(int s) {
	int n = cost.length;
	d = new int[n];
	prev = new int[n];
	boolean[] used = new boolean[n];
	Arrays.fill(d, INF);
	Arrays.fill(prev, -1);
	d[s] = 0;
	
	while (true) {
		int v = -1;
		for (int u = 0; u &lt; n; u++) {
			if (!used[u] &amp;&amp; (v == -1 || d[u] &lt; d[v])) v = u;
		}
		
		if (v == -1) break;
		used[v] = true;
		
		for (int u = 0; u &lt; n; u++) {
			d[u] = Math.min(d[u], d[v]+cost[v][u]);
			prev[u] = v;
		}
	}
}
}}    </description>
    <dc:date>2013-10-08T12:54:29+09:00</dc:date>
    <utime>1381204469</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/procom/pages/9.html">
    <title>data structure</title>
    <link>https://w.atwiki.jp/procom/pages/9.html</link>
    <description>
      -union find木
#highlight(java){{
	class UnionFind {
	int[] par;
	int[] rank;
	int n;
	
	UnionFind(int n) {
		par = new int[n];
		rank = new int[n];
		this.n = n;
		for (int i = 0; i &lt; n; i++)
			par[i] = i;
	}
	
	//木の根を求める
	//0&lt;=x&lt;nでないのとき-1を返す
	int find (int x) {
		if (x &lt; 0 || n &lt;= x) return -1;
		if (par[x] == x) 
			return x;
		else 
			return par[x] = find(par[x]);
	}
	
	//xとyの属する集合を併合
	//範囲外のとき-1を返す．それ以外は0を返す．
	int unite (int x, int y) {
		if (x &lt; 0 || n &lt;= x || y &lt; 0 || n &lt;= y) return -1;
		x = find(x);
		y = find(y);
		if (x == y) return 0;
		
		if (rank[x] &lt; rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
		return 0;
	}
	
	//xとyが同じ集合に属するか否か
	boolean same(int x, int y) {
		return find(x) == find(y);
	}
}	
}}    </description>
    <dc:date>2013-10-07T22:37:02+09:00</dc:date>
    <utime>1381153022</utime>
  </item>
  </rdf:RDF>
