#P7661. [COCI 2014/2015 #5] TRAKTOR
[COCI 2014/2015 #5] TRAKTOR
Description
Given points on a plane, each point has coordinates given by positive integers . Find the minimum such that among the first points, there are at least points lying on the same row, or the same column, or the same diagonal-parallel slanted line.
Input Format
The first line contains two positive integers .
The next lines each contain two positive integers .
Output Format
Output one positive integer . If there is no solution, output .
4 3
1 2
3 4
3 2
4 5
4
7 4
3 1
2 2
4 1
3 2
2 3
1 4
1 3
6
5 2
1 1
2 1
1 2
1 3
1 4
2
Hint
For of the testdata, .
For of the testdata, , .
Sample 1 Explanation:
.
Translated from COCI 2014/2015 CONTEST #5.
Translated by ChatGPT 5
京公网安备 11011102002149号