USACO Silver 2020 December - Rectangular Pasture

Author: Kevin Sheng

Official Analysis (C++)

Video Solution

Implementation

Note: the algorithm in the code may differ from that described in the video.

C++

#include <iostream>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main() {

Java

import java.io.*;
import java.util.*;
public final class RPasture {
public static void main(String[] args) throws IOException {
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
int cowNum = Integer.parseInt(read.readLine());
HashSet<Integer> seenX = new HashSet<>();
HashSet<Integer> seenY = new HashSet<>();

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!