Problem I
How many squares?

While browsing the internet, of course using Internet Explorer without any adblocker, you have noticed a number of interesting competitions advertised in the panels on various webpages. In most of these competitions you need to answer a simple question, like how many triangles/squares/rectangles there are in a picture, or even choose the right answer out of three possibilities. Despite the simplicity of the task, it seems that there are many valuable prizes to be won. So there is definitely something to compete for!
In order to increase your chances, you decided to write a
simple program that will solve the problem for you. You decided
to focus first on the question “How many squares are there in
the picture?”, and to simplify the problem even more, you
assume that the input picture consists only of a number of
lines that are infinite in both directions. To be precise, we
say that four lines
Input
The first line of the input contains a single integer
Output
Output exactly one line with one integer, denoting the total number of squares formed by the lines in the picture.
Sample Input 1 | Sample Output 1 |
---|---|
10 0 0 1 0 0 1 1 1 0 2 2 2 0 0 0 4 1 -1 1 0 2 -2 2 2 1 1 2 2 1 1 0 2 3 1 2 2 1 3 0 2 |
6 |