Skip to content

Instantly share code, notes, and snippets.

/*
O(n^2)ならば間に合う。グラフを辿る処理はO(n)なので、各ノードでO(n)の処理はでき
る。
tree1のノードiとtree2のノードjについて、ノードiをルートとする部分木のサイズと、
ノードjをルートとする部分木のサイズ、両方の部分木に共通して含まれるノードの個数
を求めておけば、ノードiとノードjからルートに向かうエッジをそれぞれ取り除いた場合
の、S(e1, e2)が計算できる。
両方の部分木に共通して含まれるノード数は、事前に部分木にノードが含まれるかどうか
を調べておけば良い。
ケース: Antec P100 10,730
マザー: Asus Z97-PRO 24,818
CPU: Intel Core-i7-4790 35,480
CPUクーラー: ENERMAX ETS-T40-BK 5,572
メモリ: CFD-Elixir DDR3 1600 8GBx2 16,566
OS: Windows 8.1 Pro 64bit 17,180
電源: オウルテック FSP RAIDER RA-750 7,953
光学ドライブ: 使い回し
SSD: Intel SSD 730 240GB 25,368
HDD: HGST Deskstar 4TB 17,610
@kusano
kusano / alert.js
Created May 29, 2014 16:05
alert(location)
alert(location);
@kusano
kusano / DataPacking.py
Created May 31, 2014 16:32
Google Code Jam 2014 Round 2 A Data Packing
for test in range(input()):
N, X = map(int, raw_input().split())
S = map(int, raw_input().split())
S.sort()
ans = 0
a, b = 0, N-1
while a<=b:
if a<b and S[a]+S[b] <= X:
a += 1
b -= 1
@kusano
kusano / UpandDown.py
Created May 31, 2014 16:33
Google Code Jam 2014 Round 2 B Up and Down
for test in range(input()):
N = input()
A = map(int, raw_input().split())
ans = 0
for i in range(N):
l = 0
r = 0
for j in range(N):
if A[j]>A[i]:
if j<i:
@kusano
kusano / Nile.cpp
Created May 31, 2014 16:34
Google Code Jam 2014 Round 2 C Don't Break The Nile
#include <iostream>
#include <vector>
#include <set>
using namespace std;
// 蟻本
const int MAX_V = 10*1024*1024;
struct edge { int to, cap, rev; };
@kusano
kusano / TrieSharding.py
Created May 31, 2014 16:36
Google Code Jam 2014 Round 2 D Trie Sharding
import itertools
def trie(S):
X = {}
n = 1
for s in S:
p = X
for c in s:
if c not in p:
p[c] = {}
@kusano
kusano / RectanglesAndHoles.cpp
Created June 4, 2014 17:08
TopCoder Open 2014 MM Round2
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdarg>
#include <set>
#include <ctime>
#include <cstring>
using namespace std;
@kusano
kusano / CollageMaker.cpp
Created July 10, 2014 01:17
TopCoder Open Marathon 2014 Round 3 CollageMaker
/*
TopCoder Open Marathon 2014 Round 3 CollageMaker
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdarg>
#include <cmath>
#include <ctime>
@kusano
kusano / gist:ea74ebc20a9deb40110b
Last active August 29, 2015 14:04
スクフェス退部部員リスト
覚醒・絆MAX・LvMAXにして処分した部員リスト
スマイル
・桜坂しずく
・須田いるか
・永山みなみ
・佐伯麗音
・森嶋ななか
・近江遙
・支倉かさね