시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 73 14 14 23.333%

문제

평면상에 N개의 직교 정사각형이 있다. 직교라는 말의 의미는 정사각형의 각 변이 모두 축(x축, y축)에 평행하다는 의미이다. 정사각형의 각 꼭지점은 정수이며, 정사각형들끼리 닿아 있거나 겹치는 경우는 없다.

이러한 사각형들이 주어졌을 때, 원점 O(0, 0)에서 보이는 정사각형의 개수를 세는 프로그램을 작성하시오.

정사각형의 테두리에 있는 서로 다른 두 점 A, B에 대해서 삼각형 OAB의 내부(삼각형의 경계를 제외하고)에 다른 사각형이 지나지 않을 경우, 그 사각형이 원점에서 보인다고 정의하자.

입력

첫째 줄에 N(1≤N≤1,000)이 주어진다. 다음 N개의 줄에는 각 직교 정사각형을 나타내는 세 정수 X, Y, L(1≤X, Y, L≤10,000)이 주어진다. 이는 사각형의 왼쪽 아래 좌표가 (X, Y)이고 변의 길이가 L이라는 의미이다.

출력

첫째 줄에 보이는 정사각형의 개수를 출력한다.

예제 입력 1

3
2 6 3
1 4 1
3 4 1

예제 출력 1

3
W3sicHJvYmxlbV9pZCI6IjIzOTciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJjZjRcdWM3NzRcdWIyOTQgXHVjODE1XHVjMGFjXHVhYzAxXHVkNjE1IiwiZGVzY3JpcHRpb24iOiI8cD5cdWQzYzlcdWJhNzRcdWMwYzFcdWM1ZDAgTlx1YWMxY1x1Yzc1OCBcdWM5YzFcdWFkNTAgXHVjODE1XHVjMGFjXHVhYzAxXHVkNjE1XHVjNzc0IFx1Yzc4OFx1YjJlNC4gXHVjOWMxXHVhZDUwXHViNzdjXHViMjk0IFx1YjlkMFx1Yzc1OCBcdWM3NThcdWJiZjhcdWIyOTQgXHVjODE1XHVjMGFjXHVhYzAxXHVkNjE1XHVjNzU4IFx1YWMwMSBcdWJjYzBcdWM3NzQgXHViYWE4XHViNDUwIFx1Y2Q5NSh4XHVjZDk1LCB5XHVjZDk1KVx1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