Codeforces Round #242 (Div. 2) Tutorials and Solutions

A. Squats

Trun x => X or X => x to make the number of 'x' is equal to the number of 'X'.

n = int(raw_input())
hamsters = [c for c in raw_input()]

sits = hamsters.count('x')
stands = hamsters.count('X')

if sits == stands:
    print 0
    print ''.join(hamsters)
else:
    if sits > stands …
more ...


"alloca" vs "placement new"

WHAT?!

For most time, we use malloc or new for memory allocation, which will get it on heap.

However, access memory on heap is not as effective as the memory on stack, because the heap is "free-floating region of memory". To the contrary, memory on stack is managed by CPU …

more ...

GeoHash算法

GeoHash

Geohash is a latitude/longitude geocode system invented by Gustavo Niemeyer when writing the web service at geohash.org, and put into the public domain. It is a hierarchical spatial data structure which subdivides space into buckets of grid shape.

简单说,GeoHash是一个将经纬度信息编码成一个string的算法。从而便于储 …

more ...




匈牙利算法

概念

交错路

交错路:设P是图G的一条路,如果P的任意两条相邻的边一定是一条属于M而另一条不属于M,就称P是一条交错路。

通俗点来说,就是把一个图中的路径染成红黑两种。然后找出一条路,使这条路红黑 …

more ...

Codeforces 3C - Tic-tac-toe

啥?

Tic-tac-toe是我很久之前在CF上做的一道题。非常考细心的模拟题。

最近有同学和我讨论过类似的问题。于是拿出来重新做一遍。练练手。

原题做 …

more ...