当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6150:Vertex Cover

Special Judge 特殊评判
题目描述
As we know, $minimum vertex cover$ is a classical NP-complete problem. There will not be polynomial time algorithm for it unless $P = NP$.

You can see the definition of vertex cover in https://en.wikipedia.org/wiki/Vertex_cover.

Today, little M designs an "approximate" algorithm for vertex cover. It is a greedy algorithm. The main idea of her algorithm is that always choosing the maximum degree vertex into the solution set. The pseudo code of her algorithm is as follows:

We assume that the labels of the vertices are from 1 to n.

for (int i = 1; i <= n; ++i) {
  use[i] = false;
deg[i] = degree of the vertex i;
}
int ans = 0;
while (true) {
  int mx = -1, u;
for (int i = 1; i <= n; ++i) {
  if (use[i])
  continue;
if (deg[i] >= mx) {
  mx = deg[i];
u = i;
}
}
if (mx <= 0)
  break;
++ans;
use[u] = true;
for (each vertex v adjacent to u)
  --deg[v];
}
return ans;


As a theory computer scientist, you immediately find that it is a bad algorithm. To show her that this algorithm dose not have a constant approximate factor, you need to construct an instance of vertex cover such that the solution get by this algorithm is much worse than the optimal solution.

Formally, your program need to output a simple undirected graph of at most $500$ vertices. Moreover, you need to output a vertex cover solution of your graph. Your program will get Accept if and only if the solution size get by the above algorithm is at least three times as much as yours.
输入解释
There is no input.
输出解释
First, output two integer $n$ and $m$ in a line, separated by a space, means the number of the vertices and the number of the edges in your graph.
In the next $m$ lines, you should output two integers $u$ and $v$ for each line, separated by a space, which denotes an edge of your graph. It must be satisfied that $1 \leq u,v \leq n$ and your graph is a simple undirected graph.
In the next line, output an integer $k(1 \leq k \leq n)$, means the size of your vertex cover solution.
Then output $k$ lines, each line contains an integer $u(1 \leq u \leq n)$ which denotes the label of a vertex in your solution. It must be satisfied that your solution is a vertex cover of your graph.
输出样例
4 4
1 2
2 3
3 4
4 1
2
1
3

提示
The sample output is just to exemplify the output format.
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6150

最后修改于 2020-10-25T23:28:49+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 256000/256000K(Java/Others)