USACO Bronze 2016 December - Block Game

Authors: Óscar Garries, tickox, Dong Liu

Official Analysis

C++

C++ Implementation

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

Python

1import sys
2
3sys.stdin = open("blocks.in", "r")
4sys.stdout = open("blocks.out", "w")
5
6def countfreq(s):
7 freqs = [0]*26
8 for c in s:
9 freqs[ord(c)-ord('a')] += 1
10 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!

Give Us Feedback on USACO Bronze 2016 December - Block Game!