QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#10653. Kręgi w zbożu

统计

许多 Bajtocji 的农民还会长时间地回忆起去年的夏天。而这并不是因为那一年的收成特别好,或者恰恰相反——因为干旱和冰雹,而是因为许多小麦田里出现了神秘的圆环。作为 Bajtocji 各种奇怪问题的专家,Bajtazar 决定从科学的角度研究这些圆环现象。为此,他对田地进行了细致的检查。他发现每一个圆环都是在一个圆形区域内压倒庄稼形成的。任意两个圆环至多在一个点上相交(特别地,一个圆环不能完全处于另一个圆环内部)。

Bajtazar 怀疑这些圆环是外星生物发送的信息。可惜,理解它们的语言将会非常困难。目前,Bajtazar 建立了一个圆环排列的数据库,并致力于对它们进行统计分析。Bajtazar 收集的数据越有趣,就越好。他请你写一个程序,对于给定的圆环排列,输出有多少对圆环有公共点。

输入格式

输入的第一行是一个整数 $ n $ ($1 \le n \le 500\,000$),表示圆环的数量。接下来的 $ n $ 行,每行描述一个圆环。在第 $i$ 行有三个整数 $ x_{i} $, $ y_{i} $, $ r_{i} $ ($-10^{9} \le x_{i}, y_{i} \le 10^{9}$, $1 \le r_{i} \le 10^{9}$)。表示第 $i$ 个圆环的圆心在 $(x_{i}, y_{i})$,半径为 $ r_{i} $。

输出格式

你的程序应输出有公共点的圆环对的数量。

样例

输入

4
0 0 5
8 6 5
-6 8 5
2 14 5

输出

4
problem_10653_1.gif?
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.