Posts

Showing posts from April, 2020

Code Jam 2020 Qualification Round

Image
Problem: Vestigium  Vestigium means "trace" in Latin. In this problem we work with Latin squares and matrix traces. The  trace  of a square matrix is the sum of the values on the main diagonal (which runs from the upper left to the lower right). An  N -by- N  square matrix is a  Latin square  if each cell contains one of  N  different values, and no value is repeated within a row or a column. In this problem, we will deal only with "natural Latin squares" in which the  N  values are the integers between 1 and  N . Given a matrix that contains only integers between 1 and  N , we want to compute its trace and check whether it is a natural Latin square. To give some additional information, instead of simply telling us whether the matrix is a natural Latin square or not, please compute the number of rows and the number of columns that contain repeated values. Input The first line of the input gives the num...