intさわだんのBlack History

刹那的レジェンドになりたい。

memo

POJ 2104 K-th Number

例の平方分割で解ける問題バケットのサイズを色々試してみた。B = 1100 → TLE (>20000MS) B = 1000 → 11735MS B = 900 → 11782MS B = 850 → 11829MS B = 800 → 11157MS B = 700 → 12235MS結果B = 800が一番早い(?) #include <cstdio> #include <vector> #include <algorithm> using n</algorithm></vector></cstdio>…

LCA memo 最小共通祖先 lca c++

http://abc014.contest.atcoder.jp/tasks/abc014_4完全にmemoで保存用O(N^2) #include <bits/stdc++.h> using namespace std; const int M = 100010; vector<int> G[M]; int root; int n,q; int parent[M]; int depth[M]; void dfs(int v,int p,int d){ parent[v] = p; depth[v] </int></bits/stdc++.h>…

poj 3977

なぜかWAになる こんどまた解き直す。 保存用 #include <cstdio> #include <iostream> #include <algorithm> #include <cstdlib> using namespace std; int n,n2; long long int d[50]; typedef pair<long long int,int> P; P ps[1 << (40 / 2)]; int main(){ while(1){ scanf("%d",&n); if(n == 0)break; for(int i = </long></cstdlib></algorithm></iostream></cstdio>…

TO DO

charのprintf,scanfmapのキーがcharの場合についての勉強が必要。

第5回日本情報オリンピック 予選 問題2

Nの範囲が記述されていないから、ちょっとダメな問題ではないか…まあいいや。 map使いたかったけどキーをcahrにしたら闇になるから闇。実行速度の関係から、あんまりiostream系を使うのはよくないと思います。 #include <iostream> using namespace std; int main(){ w</iostream>…

2014の目標(今更

点数制にしよう。また今年(2014)の大みそかで紅白見てる時ぐらいに振り返ろうと思います。 目標点数 ソフト系 ~ 1800p(point) セキュリティ系 ~ 605p 競プロ系 ~ 700p 競プロ過去問 ~ 1850p 勉強系 ~ 600p 合計 ~ 5955p せめて5000pは超えたい。超えな…

joi予選過去問 宿題 (Homework)

おそらく私が人生で一番初めに解いたであろう問題を初心に戻ると言う意を込めて解いてみた。問題文 初めのころはこれぐらいの問題も20分ぐらい考えてたものなんですよ。 今となってはいい思い出かな。 この問題やってなかったら今の自分は無かったかもしれな…

memo union-find

int par[MAX_N]; //親 int rank[MAX_N]; //木の深さ //n要素で初期化 void init(int n) { for(int i = 0;i < n;i++){ par[i] = i; rank[i] = 0; } } //木の根を求める int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } …

memo dijkstra

#include <cstdio> #include <algorithm> #include <queue> #include <vector> const int INF = 10000; using namespace std; // struct edge { int to ,cost; }; struct edge { int to, cost; edge(int _to, int _cost) {to = _to; cost=_cost;} }; typedef pair<int ,int>P; int V; vector<edge> G[8]; int d[</edge></int></vector></queue></algorithm></cstdio>…

memo ワーシャル=フロイド法

完全にメモです。 #include <cstdio> #include <algorithm> #include <iostream> using namespace std; int dp[8][8] = {0}; int V; const int INF = 10000; void wf(){ for(int k = 0;k < V;k++){ for(int i = 0;i < V;i++){ for(int j = 0;j < V;j++) dp[i][j] = min(dp[i][j],dp[i][k] </iostream></algorithm></cstdio>…