USACO Bronze 2016 December - Block Game

Authors: Óscar Garries, Franek Antoniak, Dong Liu


Official Analysis (Java)

Implementation

Time Complexity: O(NS)\mathcal{O}(NS), where SS is the maximum length of a string.

C++

#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using std::cout;
using std::endl;
using std::string;
using std::vector;

Java

import java.io.*;
import java.util.*;
public class Blocks {
public static void main(String[] args) throws IOException {
Kattio io = new Kattio("blocks");
int n = io.nextInt();
String[][] words = new String[n][];
for (int i = 0; i < n; i++) {
words[i] = new String[] {io.next(), io.next()};

Python

from typing import List
def count_freq(s: str) -> List[int]:
"""
:return: An array of length 26, containing the frequency
of each character in the given string.
"""
freq = [0] * 26
for c in s:

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!