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

建议使用的浏览器:

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

6254:Rikka with Linker

题目描述
You will be familiar with the linker of C++ if you have ever compiled C++ projects in the command line. If you want to use two static libraries $liba.a$ and $libb.a$ while $liba.a$ relies on $libb.a$, you need to put $liba.a$ before $libb.a$ in your command such as $g++$ $-o$ $my$ $my.cpp$ $liba.a$ $libb.a$.

What if both $liba.a$ and $libb.a$ rely on each other? You need to add their names to the command several times such as $g++$ $-o$ $my$ $my.cpp$ $liba.a$ $libb.a$ $liba.a$. Formally, if you want to use two libraries $liba.a$ and $libb.a$ while $liba.a$ relies on $libb.a$ in your command, there must be at least one $liba.a$ which occurs before one $libb.a$.

Now, Rikka is working on her C++ project, and there are $n$ static libraries she will use. There are $m$ pairs of dependency relationships $(i, j)$ which means the $i$th project relies on the $j$th project.

You know, a complicated command will never bring happiness. So Rikka wants to simplify the compile command, i.e., Rikka wants to make the number of the names of static libraries in her compile command as small as possible. So she wants you to find out this number.
输入解释
The first line contains a single integer $t(1 \leq t \leq 10^3)$, the number of the testcases.

The first line of each testcase contains two numbers $n$ and $m(1 \leq n \leq 18, 0 \leq m \leq n(n-1))$.

Then $m$ lines follow, each line contains two numbers $a$ and $b(1 \leq a,b \leq n, a \neq b)$, which describes a dependency relationship: library $a$ relies on $b$.

The input guarantees that each dependency relationship will occur at most once and there are at most $20 $ testcases with $n > 12$.
输出解释
For each testcase, output a single line with a single number: the answer.
输入样例
3
3 2
1 2
2 3
3 3
1 2
2 3
3 1
5 7
1 2
2 3
3 5
5 4
4 2
2 5
3 1
输出样例
3
4
6
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6254

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

共提交 0

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