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

建议使用的浏览器:

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

5727:Necklace

题目描述
SJX has 2*N magic gems. $N$ of them have Yin energy inside while others have Yang energy. SJX wants to make a necklace with these magic gems for his beloved BHB. To avoid making the necklace too Yin or too Yang, he must place these magic gems Yin after Yang and Yang after Yin, which means two adjacent gems must have different kind of energy. But he finds that some gems with Yang energy will become somber adjacent with some of the Yin gems and impact the value of the neckless. After trying multiple times, he finds out M rules of the gems. He wants to have a most valuable neckless which means the somber gems must be as less as possible. So he wonders how many gems with Yang energy will become somber if he make the necklace in the best way.
输入解释
  Multiple test cases.

  For each test case, the first line contains two integers $N (0 \leq N \leq 9), M (0 \leq M \leq N * N)$, descripted as above.

  Then $M$ lines followed, every line contains two integers $X,Y$, indicates that magic gem $X$ with Yang energy will become somber adjacent with the magic gem $Y$ with Yin energy.
输出解释
One line per case, an integer indicates that how many gem will become somber at least.
输入样例
2 1
1 1
3 4
1 1
1 2
1 3
2 1
输出样例
1
1
来自杭电HDUOJ的附加信息
Author HIT
Recommend wange2014

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

源链接: HDU-5727

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

共提交 0

通过率 --%
时间上限 内存上限
3000/1500MS(Java/Others) 65536/65536K(Java/Others)