시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 76 15 15 24.590%

문제

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