POJ 3295:Tautology】的更多相关文章

Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10482   Accepted: 3982 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s…
题目网址:http://poj.org/problem?id=3295 题目: Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13231   Accepted: 5050 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the po…
http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1的边不一定的树,然后给出问题:询问区间和 或者 节点值更新. HDU 3887: 题意:和POJ 3321的题意差不多,只不过对每个节点询问不包含该节点的区间和 思路:今天才学了下才知道有DFS序这种东西,加上树状数组处理一下区间和 和 节点更新. DFS序大概就是我们在DFS遍历一棵树的时候,在进…
POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 3669 Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Sciss…
题目:http://poj.org/problem?id=3295 题意:p,q,r,s,t,是五个二进制数. K,A,N,C,E,是五个运算符. K:&& A:||N:! C:(!w)||x E:w==x 题意是让求如果对于五个数的所有情况一个式子总是恒为1,那么这个式子就是tautology.输出tautology. 否则输出not. 5个数,最多有2^5种情况. 判断式子是不是恒为1,只需要从后往前判断即可. 这题好长时间没看懂,代码也是看网上大神的 #include<iost…
题目链接:http://poj.org/problem?id=3295 思路分析:判断逻辑表达式是否为永真式问题.根据该表达式的特点,逻辑词在逻辑变量前,类似于后缀表达式求值问题. 算法中使用两个栈,从表达式的后边开始处理表达式中每个字符:若为逻辑变量,使其入栈SR,否则从栈SR中弹出两个逻辑变量, 进行运算后的结果再入栈SR:直到处理完表达式所有的字符.(PS:使用栈可以很好的处理广义表类似的序列) 代码如下: #include <iostream> #include <stack&g…
http://poj.org/problem?id=3295 题意: 判断表达式是否为永真式. 思路: 把每种情况都枚举一下. #include<iostream> #include<string> #include<cstring> using namespace std; ; int sta[MAXN]; char str[MAXN]; int p, q, r, s, t; void judge() { ; int len = strlen(str); ; i &g…
题目链接: http://poj.org/problem?id=3295 题目描述: 给一个字符串,字符串所表示的表达式中p, q, r, s, t表示变量,取值可以为1或0.K, A, N, C, E 分别表示且,或,非,真蕴含,等值.问表达式是不是永真的,如果是输出“tautology”,否则输出“not”. 解题思路: 这里借用到了递归的本质,也就是对栈的模拟,用递归进行压栈,求表达式的值,再加上对变量状态压缩进行枚举. #include <cstdio>//本代码用G++交就ac,c+…
Tautology Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s, t. A Well-formed formula (WFF) is any string of these symbols obeying the followin…
字母:K, A, N, C, E 表示逻辑运算 字母:p, q, r, s, t 表示逻辑变量 0 或 1 给一个字符串代表逻辑表达式,如果是永真式输出tautology 否则输出not 枚举每个逻辑变量的值,5个变量,共2^5种情况,对于每种情况都为真则为永真式. 代码: /*************************************** Problem: 3295 User: Memory: 688K Time: 0MS Language: G++ Result: Accept…
Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7716   Accepted: 2935 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s,…
Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9302   Accepted: 3549 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s,…
点击打开链接 Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8127   Accepted: 3115 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q…
Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9580   Accepted: 3640 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s,…
  Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10437   Accepted: 3963 Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s, t. A W…
http://poj.org/problem?id=1459 题意:有np个发电站,nc个消费者,m条边,边有容量限制,发电站有产能上限,消费者有需求上限问最大流量. 思路:S和发电站相连,边权是产能上限,消费者和T相连,边权是需求上限,边的话就按题意加就好了.难点更觉得在于输入..加个空格..边数组要*2,因为有反向边. #include <cstdio> #include <algorithm> #include <iostream> #include <cs…
http://poj.org/problem?id=3436 题意:题意很难懂.给出P N.接下来N行代表N个机器,每一行有2*P+1个数字 第一个数代表容量,第2~P+1个数代表输入,第P+2到2*P+1是代表输出 输入有三种情况,0,1,2.输出有0,1两种情况输入0代表不能有这个接口,1代表必须要有这个接口,2代表这个接口可有可无.输出0代表有这个接口,1代表没有这个接口.大概输出就是像插头,输入像插座,只有接口吻合才可以相连. 思路:比较简单的最大流,主要是理解题意很难,把每台机器拆成输…
http://poj.org/problem?id=2195 题意:有一个地图里面有N个人和N个家,每走一格的花费是1,问让这N个人分别到这N个家的最小花费是多少. 思路:通过这个题目学了最小费用最大流.最小费用最大流是保证在流量最大的情况下,使得费用最小. 建图是把S->人->家->T这些边弄上形成一个网络,边的容量是1(因为一个人只能和一个家匹配),边的费用是曼哈顿距离,反向边的费用是-cost. 算法的思想大概是通过SPFA找增广路径,并且找的时候费用是可以松弛的.当找到这样一条增…
http://poj.org/problem?id=3281 题意:有n头牛,f种食物,d种饮料,每头牛有fnum种喜欢的食物,dnum种喜欢的饮料,每种食物如果给一头牛吃了,那么另一个牛就不能吃这种食物了,饮料也同理,问最多有多少头牛可以吃到它喜欢的饮料和食物. 思路:一开始还以为二分匹配可以做,当然如果只有食物或者饮料其中一种就可以做.难点在于建图.看了下书,因为要保证经过牛的流量是1(每种食物对应分配给一头牛,每种饮料对应分配给一头牛,避免一头牛吃多份),所以要把牛拆成两个点.形成这样的路…
http://poj.org/problem?id=3580 题意:有6种操作,其中有两种之前没做过,就是Revolve操作和Min操作.Revolve一开始想着一个一个删一个一个插,觉得太暴力了,后来发现可以把要放到前面的一段切开,丢到前面去,就和上一题的Cut是一样的了.还有Min操作,一开始特别ZZ地想着只要找keytree的最左边就好了,然后发现并不是那样的,要维护一个 mi 值,一开始两个节点设成 INF,然后 pushup 的时候先把 val 赋给 mi,然后再和左右儿子对比.WA了…
http://poj.org/problem?id=3237 题意:树链剖分.操作有三种:改变一条边的边权,将 a 到 b 的每条边的边权都翻转(即 w[i] = -w[i]),询问 a 到 b 的最大边权. 思路:一开始没有用区间更新,每次翻转的时候都更新到叶子节点,居然也能过,后来看别人的发现也是可以区间更新的. 第一种:无区间更新水过 #include <cstdio> #include <algorithm> #include <iostream> #inclu…
http://poj.org/problem?id=2763 题意:给出 n 个点, n-1 条带权边, 询问是询问 s 到 v 的权值, 修改是修改存储时候的第 i 条边的权值. 思路:树链剖分之修改边权.边权的修改, 与点权修改不同的地方在于, 线段树中存的点是边,其中每条边边是以 儿子 的时间戳来记录的.例如: u -> v , dep[u] < dep[v], 说明 u 是 v 的父亲,所以这条边在线段树中的编号就是以 tid[v]. #include <cstdio> #…
http://poj.org/problem?id=3349 Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 37609   Accepted: 9878 Description You may have heard that no two snowflakes are alike. Your task is to write a program to determine…
http://poj.org/problem?id=1260 Pearls Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8474   Accepted: 4236 Description In Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls…
http://poj.org/problem?id=3903 Stock Exchange Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5983   Accepted: 2096 Description The world financial crisis is quite a subject. Some people are more relaxed while others are quite anxious. J…
http://poj.org/problem?id=3267 The Cow Lexicon Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9380   Accepted: 4469 Description Few know that the cows have their own dictionary with W (1 ≤ W ≤ 600) words, each containing no more 25 of t…
http://poj.org/problem?id=3026 Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12086   Accepted: 3953 Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg coll…
http://poj.org/problem?id=2192 Zipper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17585   Accepted: 6253 Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the…
ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6281 Accepted: 3769 Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby…
http://poj.org/problem?id=2104 题意:给出n个数和m个询问求区间第K小. 思路:以前用主席树做过,这次学整体二分来做.整体二分在yr大佬的指点下,终于大概懂了点了.对于二分能够解决的询问,如果有多个,那么如果支持离线处理的话,那么就可以使用整体二分了. 在这题二分可行的答案,根据这个答案,把询问操作丢在左右两个队列里面分别递归继续按这样处理.注释里写的很详细. #include <iostream> #include <cstdlib> #includ…