图论——2-SAT
Alex_McAvoy
想要成为渔夫的猎手
展开
-
图论 —— 2-SAT 问题
【问题概述】2-SAT问题是这样的:有n个布尔变量xi,另有m个需要满足的条件,每个条件的形式都是“xi为真/假或者xj为真/假“SAT 是适定性(Satisfiability)问题的简称,一般形式为:k-适定性问题,简称:k-SAT。当 k>2 时,k-SAT 是 NP 完全的,因此一般讨论的是 k=2 的情况,即:2-SAT 问题。关于 2-SAT 问题,简单的来说就是给...原创 2019-03-15 20:59:32 · 8337 阅读 · 4 评论 -
Party(HDU-3062)
Problem Description有n对夫妻被邀请参加一个聚会,因为场地的问题,每对夫妻中只有1人可以列席。在2n 个人中,某些人之间有着很大的矛盾(当然夫妻之间是没有矛盾的),有矛盾的2个人是不会同时出现在聚会上的。有没有可能会有n 个人同时列席?Inputn: 表示有n对夫妻被邀请 (n<= 1000)m: 表示有m 对矛盾关系 ( m < (n - 1) * ...原创 2019-07-29 10:06:55 · 420 阅读 · 0 评论 -
2-SAT 问题(洛谷-P4782)
题目描述有n个布尔变量x1~xn,另有m个需要满足的条件,每个条件的形式都是“xi为true/false或xj为true/false”。比如“x1为真或x3为假”、“x7为假或x2为假”。2-SAT 问题的目标是给每个变量赋值使得所有条件得到满足。输入输出格式输入格式:第一行两个整数n和m,意义如体面所述。接下来m行每行4个整数 i a j b,表示“xi为a或xj为b”(a...原创 2019-07-29 09:34:57 · 586 阅读 · 0 评论 -
处女座与宝藏
【题目描述】处女座进行了一次探险,发现了一批宝藏。如果他获得这批宝藏,那么他一辈子都不需要工作了。但是处女座遇到了一个难题。宝藏被装在n个宝箱里,宝箱编号为1,2,…,n,只有所有宝箱在某一时间被打开,处女座才能获得宝藏。有m个开关,每个开关控制k个宝箱,如果按下一个开关,那么这k个宝箱的开关状态都会发生改变(从开启变成关闭,从关闭变成开启),处女座想知道他能否获得这批宝藏。【输入描...原创 2019-05-09 12:27:45 · 476 阅读 · 0 评论 -
Go Deeper(HDU-3715)
Problem DescriptionHere is a procedure's pseudocode:go(int dep, int n, int m)beginoutput the value of dep.if dep < m and x[a[dep]] + x[b[dep]] != c[dep] then go(dep + 1, n, m)endIn this ...原创 2018-12-18 14:51:27 · 537 阅读 · 0 评论 -
Perfect Election(POJ-3905)
Problem DescriptionIn a country (my memory fails to say which), the candidates {1, 2 ..., N} are running in the parliamentary election. An opinion poll asks the question "For any two candidates of ...原创 2018-12-11 17:54:44 · 361 阅读 · 0 评论 -
Building roads(POJ-2749)
Problem DescriptionFarmer John's farm has N barns, and there are some cows that live in each barn. The cows like to drop around, so John wants to build some roads to connect these barns. If he buil...原创 2018-12-17 17:15:48 · 392 阅读 · 0 评论 -
Priest John's Busiest Day(POJ-3683)
Problem DescriptionJohn is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the couple who get married on that day will...原创 2018-12-15 22:14:20 · 512 阅读 · 0 评论 -
Peaceful Commission(HDU-1814)
Problem DescriptionThe Public Peace Commission should be legislated in Parliament of The Democratic Republic of Byteland according to The Very Important Law. Unfortunately one of the obstacles is t...原创 2018-12-15 21:55:23 · 340 阅读 · 1 评论 -
Wedding(POJ-3648)
Problem DescriptionUp to thirty couples will attend a wedding feast, at which they will be seated on either side of a long table. The bride and groom sit at one end, opposite each other, and the br...原创 2018-12-14 16:32:23 · 570 阅读 · 0 评论 -
Ikki's Story IV - Panda's Trick(POJ-3207)
Problem Descriptionliympanda, one of Ikki’s friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such easy games and wants to play ano...原创 2019-03-02 14:44:41 · 294 阅读 · 0 评论 -
Get Luffy Out(POJ-2723)
Problem DescriptionRatish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlong. Ratish set off at once to Arlong's island. When he got there, he fo...原创 2018-12-12 21:14:31 · 281 阅读 · 0 评论 -
Katu Puzzle(POJ-3678)
Problem DescriptionKatu Puzzle is presented as a directed graph G(V, E) with each edge e(a, b) labeled by a boolean operator op (one of AND, OR, XOR) and an integer c (0 ≤ c ≤ 1). One Katu is solva...原创 2018-12-12 20:52:42 · 2366 阅读 · 0 评论 -
Let's go home(HDU-1824)
Problem Description小时候,乡愁是一枚小小的邮票,我在这头,母亲在那头。 —— 余光中集训是辛苦的,道路是坎坷的,休息还是必须的。经过一段时间的训练,lcy决定让大家回家放松一下,但是训练还是得照常进行,lcy想出了如下回家规定,每一个队(三人一队)或者队长留下或者其余两名队员同时留下;每一对队员,如果队员A留下,则队员B...原创 2018-12-12 19:31:40 · 563 阅读 · 0 评论 -
Eliminate the Conflict(HDU-4115)
Problem DescriptionConflicts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts cause quarrels, fights or even wars. How wonderful the world will be i...原创 2018-12-12 18:38:07 · 478 阅读 · 3 评论 -
满汉全席(洛谷-P4171)
题目描述满汉全席是中国最丰盛的宴客菜肴,有许多种不同的材料透过满族或是汉族的料理方式,呈现在數量繁多的菜色之中。由于菜色众多而繁杂,只有极少數博学多闻技艺高超的厨师能够做出满汉全席,而能够烹饪出经过专家认证的满汉全席,也是中国厨师最大的荣誉之一。世界满汉全席协会是由能够料理满汉全席的专家厨师们所组成,而他们之间还细分为许多不同等级的厨师。为了招收新进的厨师进入世界满汉全席协会,将于近日举...原创 2019-07-29 15:53:01 · 445 阅读 · 0 评论