시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 18 6 6 37.500%

문제

3차원 공간의 세 축 중 하나에 평행한 직사각형이 N개 있다.

적어도 한 점을 공유하는 직사각형 쌍의 개수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 직사각형의 개수 N이 주어진다. (1 ≤ N ≤ 100,000)

다음 줄에는 직사각형의 좌표 6개가 주어진다. 처음 세 숫자는 직사각형의 한 꼭지점 좌표이고, 다음 세 숫자는 그 반대편 꼭지점 좌표이다.

모든 좌표는 1보다 크거나 같고, 999보다 작거나 같은 자연수이다.

출력

첫째 줄에 적어도 한 점을 공유하는 직사각형 쌍의 개수를 출력한다.

예제 입력 1

3
1 1 1 1 3 3
1 3 3 1 6 6
1 4 4 1 5 5

예제 출력 1

2
W3sicHJvYmxlbV9pZCI6IjMwMjciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiIzXHVjYzI4XHVjNmQwIFx1YzljMVx1YzBhY1x1YWMwMVx1ZDYxNSIsImRlc2NyaXB0aW9uIjoiPHA+M1x1Y2MyOFx1YzZkMCBcdWFjZjVcdWFjMDRcdWM3NTggXHVjMTM4Jm5ic3A7XHVjZDk1IFx1YzkxMSBcdWQ1NThcdWIwOThcdWM1ZDAgXHVkM2M5XHVkNTg5XHVkNTVjIFx1YzljMVx1YzBhY1x1YWMwMVx1ZDYxNVx1Yzc3NCBOXHVhYzFjIFx1Yzc4OFx1YjJlNC48XC9wPlxyXG5cclxuPHA+XHVjODAxXHVjNWI0XHViM2M0IFx1ZDU1YyBcdWM4MTBcdWM3NDQgXHVhY2Y1XHVjNzIwXHVkNTU4XHViMjk0IFx1YzljMVx1YzBhY1x1YWMwMVx1ZDYxNSBcdWMzMGRcdWM3NTggXHVhYzFjXHVjMjE4XHViOTdjIFx1YWQ2Y1x1ZDU1OFx1YjI5NCBcdWQ1MDRcdWI4NWNcdWFkZjhcdWI3YThcdWM3NDQgXHVjNzkxXHVjMTMxXHVkNTU4XHVj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