#P10757. [WC2011] 关系挖掘

[WC2011] 关系挖掘

Problem Description

Some people say, “Any two people in the world can be connected through at most 66 people.” Little B is very interested in this, so he started some research on relationship mining in social networks.

Now Little B has obtained social network testdata containing NN people, with MM pieces of relationship information. A relationship can be represented as (ai,bi,wi)(a_i, b_i, w_i), meaning that there is a relationship between people aia_i and bib_i, and the closeness is wiw_i (wi>0w_i>0). Little B now wants to choose KK people (KNK\leq N) as research targets. To make the research more reliable, he hopes that the total closeness of relationships among these KK people is as large as possible.

This problem can be abstracted as: given a weighted undirected graph G=(V,E)G=(V, E) and an integer KK, the goal is to find a subset SS of the vertex set VV such that S=K|S|=K and the following expression is maximized:

$$\sum_{(a_i,b_i,w_i)\in E \wedge a_i\in S \wedge b_i \in S} w_i$$

Input Format

This is an output-only problem. There are 1010 input files relation*.in in your directory.

The first line of each input file contains three integers NN, MM, and KK, representing the number of vertices (people), the number of edges (relationships), and the number of vertices (people) to select, KK, in the given social network.

The next MM lines each contain three positive integers aia_i, bib_i, wiw_i, describing an edge (relationship). All vertices (people) are numbered from 11 to NN.

Output Format

For each input file, provide the corresponding output file relation*.out in the directory.

The output file should contain KK lines, each with one integer, indicating the index of one of the selected KK people.

3 2 2
1 2 3
1 3 5 
1
3 

Hint

Scoring.

For each test point, if you do not output anything or your output is invalid, you get 00 points.

For each test point, there are four scoring parameters m1m_1, m2m_2, m3m_3, and m4m_4. Suppose the sum of closeness values among the KK people selected by the contestant is cc.

  • If c>m1c>m_1, you get 1212 points.
  • If c=m1c=m_1, you get 1010 points.
  • If m1>cm2m_1>c\geq m_2, you get 88 points.
  • If m2>cm3m_2>c\geq m_3, you get 55 points.
  • If m3>cm4m_3>c\geq m_4, you get 33 points.
  • If c>0c>0, you get 11 point.
  • Otherwise, you get 00 points.

Translated by ChatGPT 5