QOJ.ac

QOJ

时间限制: 1 s 内存限制: 128 MB 总分: 100

#10762. Travel

统计

During the long-awaited summer vacation, to celebrate Xiao Bai's excellent performance in a math exam, Xiao Lan decided to take Xiao Bai on a trip.

After some deliberation, they decided to make Country T their destination. The territory of Country T can be represented by a convex $N$-sided polygon, where the $N$ vertices represent $N$ entry/exit points. Country T contains $N-2$ cities, each of which is a triangle whose vertices are vertices of the $N$-sided polygon (in other words, the cities form a triangulation of Country T). The travel route of the two can be viewed as a line segment connecting two non-adjacent vertices among the $N$ vertices.

To buy the best souvenirs, Xiao Bai hopes to pass through as many cities as possible on the travel route. As a friend of Xiao Lan, can you help them?

Input

Each input file contains only one test case.

The first line contains a single positive integer $N$, where $N$ is as described in the problem.

The next $N-2$ lines each contain three integers $p, q, r$, representing the indices of the three vertices of that city's triangle (the $N$ vertices of Country T are numbered from $1$ to $N$ in clockwise order).

Output

The output file contains a single line representing the maximum number of cities passed. (A city is considered passed if and only if it has at least two common points with the route.)

Examples

Input 1

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

Output 1

4

Constraints

For $20\%$ of the data, $N \le 2000$.

For $100\%$ of the data, $4 \le N \le 200000$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.