QOJ.ac

QOJ

حد الوقت: 0.5 s حد الذاكرة: 128 MB مجموع النقاط: 100

#4180. Morning Run

الإحصائيات

Elaxia has recently become obsessed with karate and has set up a fitness plan for himself, including push-ups, sit-ups, and so on. However, the only thing he has stuck with so far is morning jogging. Now, given a map of the area near the school, this map contains $N$ intersections and $M$ streets. Elaxia can only run from one intersection to another, and streets only intersect at the intersections. Every day, Elaxia runs from his dormitory to the school, where the dormitory is numbered $1$ and the school is numbered $N$. Elaxia's morning jogging plan is carried out in cycles (each consisting of several days). Since he does not like to take the same route, within one cycle, the jogging routes for each day must not intersect (at any intersection, excluding the dormitory and the school). Elaxia does not have great endurance; he wants the total distance run within a cycle to be as short as possible, but he also wants the number of days in the training cycle to be as long as possible. Besides practicing karate, Elaxia spends his other time studying and looking for girls, so he wants you to help him design a morning jogging plan that meets his requirements.

Input

The first line contains two numbers $N$ and $M$, representing the number of intersections and the number of streets.

The next $M$ lines each contain three numbers $a, b, c$, representing a street of length $c$ between intersection $a$ and intersection $b$ (directed).

Output

Two numbers: the first is the maximum number of days in a cycle, and the second is the shortest total distance under the condition that the number of days is maximized.

Examples

Input 1

7 10
1 2 1
1 3 1
2 4 1
3 4 1
4 5 1
4 6 1
2 5 5
3 6 6
5 7 1
6 7 1

Output 1

2 11

Subtasks

Test Case $N$ $M$
$1$ $5$ $8$
$2$ $10$ $30$
$3$ $20$ $120$
$4$ $50$ $1\,000$
$5$ $100$ $3\,000$
$6 \sim 7$ $100$ $8\,000$
$8$ $200$ $10\,000$
$9$ $200$ $12\,000$
$10$ $200$ $20\,000$

For all data, $1 \leq N \leq 200, 1 \leq M \leq 20\,000$.

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.