Mock CCC '18 Contest 5 S5 - California Boggle

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 0.6s
Java 1.0s
Memory limit: 1G

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Given an N \times N grid of letters, one can select four squares such that the first is a C, the second is an A, the third is an L, and the last is an I, and two adjacent squares in the pattern share at least a corner.

This selection process is repeated as many times as possible, with the caveat that a given square can only be selected at most once.

Compute the maximum number of distinct sets of letters that can be selected.


1 \le N \le 200

In tests worth 3 marks, you may assume N \le 4.

In tests worth an additional 5 marks, you may assume N \le 10.

Input Specification

The first line of the input contains a single integer, N.

The next N lines contain N characters, all of which appear in CALI.

Output Specification

Output, on a single line, the maximum number of sets that can be selected.

Sample Input


Sample Output



There are no comments at the moment.