USACO Silver 2020 US Open - Social Distancing

Author: Qi Wang

Official Analysis

Time Complexity: O((N+M)log(maxDist))\mathcal{O}((N+M)\log (maxDist))

Java

import java.util.*;
import java.io.*;
public class socdist{
static int N, M;
static Pair[] P;
public static void main(String[] args) throws IOException{
InputReader in = new InputReader("socdist.in");
N = in.nextInt(); M = in.nextInt(); P = new Pair[M];
for(int i = 0; i<M; i++){

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!