Skip to content

Instantly share code, notes, and snippets.

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
import os
from sys import argv
from scipy.misc import imread, imresize, imsave
input_dir = argv[1]
output_dir = './out/'
os.makedirs(output_dir, exist_ok=True)
filenames = sorted(os.listdir(input_dir))
@amoshyc
amoshyc / poj3276.md
Last active April 8, 2017 14:33
Poj 3276: Face The Right Way

Poj 3276: Face The Right Way

分析

書上例題…… 枚舉 + 貪心(dp)

我們枚舉 K,看 K 固定時需要多少次反轉次數,最直覺的寫法是:

@amoshyc
amoshyc / poj2566.md
Last active April 7, 2017 14:03
Poj 2566: Bound Found

Poj 2566: Bound Found

爬行法(尺取法)

※ 以下都是我自己著墨出來的,不保證正確

※ 以下 r+ 指的是比 r 大的數

c.NotebookApp.ip = '*'
c.NotebookApp.password = 'sha1:704dbc0c1d89:2e2c09f31e89b252b374b483ed070c64126024f4'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
@amoshyc
amoshyc / poj3169.md
Last active March 20, 2017 12:19
Poj 3169: Layout

Poj 3169: Layout

分析

這就是所謂的 差分約束系統 啊,第一次寫到…

將多個同型式的不等式轉化成最短路徑問題,原理請參

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Matlab
Exec=bash -c "~/Matlab/bin/matlab -desktop"
Icon=matlab_icon.png
Terminal=False
Categories=Development;Math;Science;Education;

Docker Usage

Start/Stop Docker

sudo systemctl start docker
sudo systemctl stop docker

Create f25 Container

@amoshyc
amoshyc / ptc_2015_12_1_a.md
Last active May 15, 2016 14:13
PTC 2015/12_1 A: Constrained 0-1 Knapsack Problem

PTC 2015/12_1 A: Constrained 0-1 Knapsack Problem

給定一些物品的價值與重量,在滿足 Wa <= 總重 <= Wb 的條件下,選至少 L 個物品出來,並使單位重量的價值 ceil(sum(w) / sum(v) 最大化。

分析

乍看之下很像可以用二分搜解的平均最大化的問題,但仔細分析可以發現, 新增加的條件會造成二分搜解法中的單調性消失,所以不能使用二分搜來解這題。

@amoshyc
amoshyc / poj3280.md
Last active May 13, 2016 05:55
Poj 3280: Cheapest Palindrome

Poj 3280: Cheapest Palindrome

分析

標準二維 dp 的題型。

###定義