[POJ3678] Katu Puzzle | 2-SAT 入门

简介: Description Katu Puzzle is presented as a directed graph G ( V , E ) with each edge e ( a , b ) labeled by a boolean operator op (oneofAND,OR,XOR) and an integer c ( 0 ≤ c ≤ 1 ) . One Katu is solvable if one can find each vertex Vi a value X i ( 0 ≤ X i ≤ 1 )

Description
Katu Puzzle is presented as a directed graph G ( V , E ) with each edge e ( a , b ) labeled by a boolean operator op (oneofAND,OR,XOR) and an integer c ( 0 ≤ c ≤ 1 ) . One Katu is solvable if one can find each vertex Vi a value X i ( 0 ≤ X i ≤ 1 ) such that for each edge e(a, b) labeled by op and c, the following formula holds:
Xa op Xb = c
The calculating rules are:
AND 0 1
0 0 0
1 0 1
OR 0 1
0 0 1
1 1 1
XOR 0 1
0 0 1
1 1 0
Given a Katu Puzzle, your task is to determine whether it is solvable.
Input
The first line contains two integers N ( 1 ≤ N ≤ 1000 )and M,( 0 ≤ M ≤ 1 , 000 , 000 ) (0 ≤ M ≤ 1,000,000) indicating the number of vertices and edges.
The following M lines contain three integers a ( 0 ≤ a < N ) , b ( 0 ≤ b < N ), c and an operator op each, describing the edges.
Output
Output a line containing “YES” or “NO”.
Sample Input

相关文章
POJ3678——Katu Puzzle(2-SAT)
POJ3678——Katu Puzzle(2-SAT)
166 0
POJ3678——Katu Puzzle(2-SAT)
|
测试技术
POJ3687---Labeling Balls
POJ3687---Labeling Balls
POJ3687---Labeling Balls
hdu-1098 Ignatius's puzzle(费马小定理)
hdu-1098 Ignatius's puzzle(费马小定理)
169 0
hdu-1098 Ignatius's puzzle(费马小定理)
[POJ3678] Katu Puzzle | 2-SAT 入门
Description Katu Puzzle is presented as a directed graph G ( V , E ) with each edge e ( a , b ) labeled by a boolean operator op (oneofAND,OR,XOR) and an integer c ( 0 ≤ c ≤ 1 ) . One Katu is solvable if one can find each vertex Vi a value X i ( 0 ≤ X i ≤ 1 )
175 0
HDU-1097,A hard puzzle(快速幂)
HDU-1097,A hard puzzle(快速幂)
|
测试技术
HDU-1847,Good Luck in CET-4 Everybody!(巴什博弈)
HDU-1847,Good Luck in CET-4 Everybody!(巴什博弈)
[POJ 3683] Priest John‘s Busiest Day | 2-SAT +Tarjan缩点跑拓扑排序
题意: 给出n个婚礼,每个婚礼有个开始的时间和结束的时间,在婚礼期间,要举行持续时间为D的活动,这个活动只能在婚礼期间的前D时间内举行,或者是在婚礼期间的后D时间内举行,问能否安排一种方式使得能够参与n个婚礼的活动 思路: 每个活动有两个选择,而且还要满足一定的条件,这显然是一个2-SAT问题 方法: 2-SAT + Tarjan 首先根据两种选择是否首尾冲突进行连边,如果冲突,则连对立的边
112 0
HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)
HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)
148 0
|
消息中间件 数据建模
题解 P1339 【[USACO09OCT]热浪Heat Wave】
题目链接 这道题纯属是一个裸的SPFA;建议先把模板AC之后再做。只需要做一些手脚,就是在加边的时候加一个双向边就好。然后再第一次加点的时候看不懂模板的出门左转度娘。推荐下面一片讲解:友链所以说,直接上代码。
1156 0