Spinning Roulettes (casino)

92 teams scored 3890 points on this task, for a maximum score of 100, an average score of 42 and a median score of 25.

Highlights

  1. Galileo Galilei, Trento is the institute with the most points (125).
  2. Lombardia is the region with the most points (735).

Statement

Kida has found herself in the casino again! In front of her, there are N roulettes, each having M pins. Each of the M pins of a roulette wheel is coded by a lowercase letter of the English alphabet. Kida considers two roulettes to be similar if the configuration of the pins of the first roulette can be obtained on the second roulette by shifting left or right all the pins of the second roulette an arbitrary number of times. Note that each shift is a cyclic shift. For example abca can be obtained from caab, but abac or aacb cannot be obtained from abca. Kida asks you to count the number of unordered pairs of similar roulettes.