Nice Enough Permutations (permutation)

17 teams scored 440 points on this task, for a maximum score of 100, an average score of 26 and a median score of 20.

Highlights

  1. Volta, Milano is the institute with the most points (100).
  2. Lombardia is the region with the most points (160).

Statement

The Romanian Scientific Committee of the IIOT loves playing around with numbers and thinking about puzzles. This time they have come up with an interesting property for permutations. When you look at the N integer numbers from 1 to N in some order, you may notice that some arrangments "look nicer" than others. After a long debate, the committee has eventually reached an agreement on what constitutes the "niceness". Consider two adjacent positions i and i + 1 in a permutation P: if the number at position i + 1 is exactly the successor of the number at position i, that pair is considered "nice" (in other words, P[i+1] - P[i] should be equal to 1). A permutation is nice enough iff at most one pair of adjacent positions does not respect the aforementioned property. Again, this means that the property should hold at least for N - 2 pairs out of the N - 1 (total number of pairs of adjacent positions)...