시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)61312954.717%

문제

Yunee is going to challenge Woongbae with a game that Yunee invented. Yunee's game is called the Vertex Merge Game and it is played on an edge-weighted connected graph. The game consists of several rounds, and each round proceeds as follows.

  1. At the start of each round, Yunee colors each vertex either red or blue. There should be at least one red vertex and one blue vertex after coloring.
  2. Yunee receives points equal to $\text{(the number of red vertices)} \times \text{(the number of blue vertices)}$.
  3. Woongbae selects an edge that connects a red vertex and a blue vertex.
  4. Woongbae receives points equal to the weight of the selected edge.
  5. Merge the two vertices at the ends of the selected edge. All edges are preserved after merging.

Repeat the rounds until there is only one vertex left in the graph. Then the game ends, and the person with higher total points wins the game.

Given a graph, find out who wins the game when both Yunee and Woongbae play the game optimally. Note that their goal is to win the game, not to maximize their points.

입력

The first line contains two integers $N$ and $M$ $(2\leq N \leq 100,000, 1\leq M \leq 300,000)$. $N$ is the number of vertices and $M$ is the number of edges.

The next $M$ lines describe the edges of the graph. The $i$-th line contains three integers $u_i, v_i, w_i$ $(1\leq u_i, v_i \leq N, 0 \leq w_i \leq 10^9)$. It represents an edge connecting $u_i$ and $v_i$ with a weight $w_i$.

It is guaranteed that the given graph is connected.

출력

If Yunee wins, output win. If Woongbae wins, output lose. If there is a tie, output tie.

예제 입력 1

3 3
1 2 3
1 3 4
2 3 1

예제 출력 1

lose

In the first example, the game may proceed as follows.

  • Yunee colors vertex $1$ with red and vertices $2, 3$ with blue. Yunee receives $1\times 2 = 2$ points.
  • Woongbae selects the edge of weight $4$ connecting vertices $1, 3$. Woongbae receives $4$ points.
  • Vertices $1$ and $3$ are merged into a single vertex.
  • Yunee colors the merged vertex with red and vertex $2$ with blue. Yunee receives $1 \times 1 = 1$ points.
  • Woongbae selects the edge of weight $3$. Woongbae receives $3$ points.
  • The two vertices are merged into a single vertex. There is only one vertex left, so the game ends.

Yunee has $3$ points and Woongbae has $7$ points in total. Woongbae wins the game.

출처

University > UNIST > 3rd UNIST Algorithm Programming Contest Uni-CODE 2021 G번