Graduation Table
시간 제한1초메모리 제한1024 MB
친구가 각각 최대 두 개의 요청을 낸 상황에서, 원탁 한 바퀴에 담을 수 있는 가장 이익이 큰 간선 집합을 고른다.
문제
You have been asked to organize the computing science graduation banquet. There are people attending the banquet, and they must all be seated around a large circular table. As it turns out, some pairs of attendees are friends and wish to sit next to each other. Thankfully, since all the attendees are computing science majors, none have more than 2 friends.
While there is no official way to request seating arrangements, these pairs have come to you privately and offered you a bribe if you fulfill their request. You care about your integrity, but you also care about money, so you will only accept bribes if you can fulfill the pair’s request. You wish to maximize the amount of money you can earn by accepting the most profitable set of bribes.
입력
The first line of input contains two integers () and (), indicating the number of banquet attendees and the number of seating requests, respectively. Then lines follow, each containing three integers , (), and () indicating that attendees and are willing to pay you dollars to sit next to each other.
It is guaranteed that any pair will submit at most one request to sit with each other, and each individual attendee will appear in at most two requests.
출력
Output the maximum number of dollars you can make over all possible seating arrangements.