USACO 3.4 American Heritage | heritage | c++

Different order of Binary tree: Recursion
Read Source Code

Posted in USACO Training | Tagged | Leave a comment

USACO 3.4 Electric Fence | fence9 | c++

Pick’s theorem
Read Source Code

Posted in USACO Training | Tagged | 3 Comments

USACO 3.3 Camelot | camelot | c++

Breadth First + Brute Force Search.
Read Source Code

Posted in USACO Training | Tagged | 5 Comments

USACO 3.3 Riding The Fences | fence | c++

Eulerian Tours
Read Source Code

Posted in USACO Training | Tagged | Leave a comment

USACO 3.3 Home on the Range | range | c++

Find all [all-1 square] in a matrix.
Classic Dynamic Programming.
range.cpp
Read Source Code

Posted in USACO Training | Tagged | Leave a comment

USACO 3.3 Shopping Offers | shopping | c++

5-dimensional dynamic programming.
Sounds hard, but actually it’s not.

Read Source Code

Posted in USACO Training | Tagged | Leave a comment

USACO 3.3 A game | game1 | c++

DP
Read Source Code

Posted in USACO Training | Tagged | Leave a comment

USACO 3.2 Sweet Butter | butter | c++

First, I though it was a Floyd-Warshall. But complexity is O(800^3) = TLE
I have two methods.
1. SPFA(shortest path faster algorithm, actually it’s a Bellman-Ford with queue)
2. Dijkstra + Heap
Read Source Code

Posted in USACO Training | Tagged | Leave a comment

USACO 3.2 Magic Squares | msquare | c++

use, string, set, queue. Just a sample dfs.
Read Source Code

Posted in USACO Training | Tagged | Leave a comment

USACO 3.2 Feed Ratios | ratios | c++

so easy…
Read Source Code

Posted in USACO Training | Tagged | Leave a comment