USACO Silver 2018 US Open - Multiplayer Moo

Author: Kevin Sheng


Official Editorial (C++)

The solution uses an iterative approach to floodfill instead of a recursive approach.

Implementation

Time Complexity: O(N2)\mathcal{O}(N^2)

C++

#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using std::cout;
using std::endl;
using std::pair;
using std::vector;

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!