408916: GYM103380 B North Pole Retirement
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
B. North Pole Retirementtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Santa has gotten quite old and is entering retirement. To get ready, he'd like to practice playing some bingo.
Santa plays a special type of bingo on a $$$N \times N$$$ grid, where each cell contains a unique number between $$$1$$$ and $$$N^2$$$. Some permutations of these numbers are called out successively. When a full row or column is called out, Santa wins!
Given Santa's board and the order in which the numbers are called, determine which number Santa will win with.
InputA single integer, $$$2 \leq N \leq 100$$$.
An $$$N \times N$$$ grid with numbers $$$1...N^2$$$, showing the board
The $$$N^2$$$ numbers, in the order they're called
OutputThe number that will cause Santa to win
ExampleInput3 2 7 9 8 3 1 6 5 4 4 6 8 7 5 3 2 9 1Output
5Note
Note that the first row/column to fill up is the bottom row.