시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB86181825.352%

문제

평면상에 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

예제 입력 2

4
1 2 1
3 1 1
2 4 2
3 7 1

예제 출력 2

2
W3sicHJvYmxlbV9pZCI6IjIzOTciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJjZjRcdWM3NzRcdWIyOTQgXHVjODE1XHVjMGFjXHVhYzAxXHVkNjE1IiwiZGVzY3JpcHRpb24iOiI8cD5cdWQzYzlcdWJhNzRcdWMwYzFcdWM1ZDAgTlx1YWMxY1x1Yzc1OCBcdWM5YzFcdWFkNTAgXHVjODE1XHVjMGFjXHVhYzAxXHVkNjE1XHVjNzc0IFx1Yzc4OFx1YjJlNC4gXHVjOWMxXHVhZDUwXHViNzdjXHViMjk0IFx1YjlkMFx1Yzc1OCBcdWM3NThcdWJiZjhcdWIyOTQgXHVjODE1XHVjMGFjXHVhYzAxXHVkNjE1XHVjNzU4IFx1YWMwMSBcdWJjYzBcdWM3NzQgXHViY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