USACO Bronze 2016 December - Block Game

Authors: Óscar Garries, tickox, Dong Liu

Official Analysis

C++

Implementation

#include <bits/stdc++.h>
using namespace std;
constexpr int nb_letter = 26;
using arr = array<int, nb_letter>;
void count_freq(const string &s, arr &freq) {
for (char c: s) {
freq[c - 'a']++;

Python

import sys
sys.stdin = open("blocks.in", "r")
sys.stdout = open("blocks.out", "w")
def countfreq(s):
freqs = [0]*26
for c in s:
freqs[ord(c)-ord('a')] += 1
return freqs

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!