<?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:11:53+09:00</dc:date>
    <utime>1397225513</utime>

    <items>
      <rdf:Seq>
                <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/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:li rdf:resource="https://w.atwiki.jp/procom/pages/8.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/procom/pages/7.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <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);
	}    </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    </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/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    </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;     </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>
    <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/7.html">
    <title>comparator</title>
    <link>https://w.atwiki.jp/procom/pages/7.html</link>
    <description>
      -Integer降順のComparator
#highlight(java){{
class DescendComparator&lt;T&gt; implements Comparator&lt;T&gt;{
	@Override
	public int compare(T o0, T o1) {
		return -((Integer)o0).compareTo((Integer)o1);
	}
}
}}    </description>
    <dc:date>2013-10-04T13:32:45+09:00</dc:date>
    <utime>1380861165</utime>
  </item>
  </rdf:RDF>
