ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 23736 |
문제명 | Vertex Merge Game |
레벨 | 플래티넘 2 |
분류 |
게임 이론 |
시간복잡도 | O(ElogE) |
인풋사이즈 | E<=300,000 |
사용한 언어 | Python 3.11 |
제출기록 | 89888KB / 820ms |
최고기록 | 820ms |
해결날짜 | 2023/07/15 |
"""Solution code for "BOJ 23736. Vertex Merge Game".
- Problem link: https://www.acmicpc.net/problem/23736
- Solution link: http://www.teferi.net/ps/problems/boj/23736
Tags: [game theory]
"""
import sys
from teflib import graph as tgraph
def main():
N, M = [int(x) for x in sys.stdin.readline().split()]
edges = []
for _ in range(M):
u, v, w = [int(x) for x in sys.stdin.readline().split()]
edges.append((u - 1, v - 1, -w))
mst_edges = tgraph.minimum_spanning_tree(edges, N)
woongbae = -sum(w for _, _, w in mst_edges)
yunee = sum((i // 2) * ((i + 1) // 2) for i in range(N + 1))
if yunee == woongbae:
print('tie')
else:
print('win' if yunee > woongbae else 'lose')
if __name__ == '__main__':
main()