随笔分类 -  OJ—poj

摘要:Priest John's Busiest Day 链接 题意: 有n场婚礼,每场婚礼有开始时间和结束时间,每场婚礼都需要牧师的祝福,祝福的时间只能是婚礼开始或者婚礼结束。问能否满足n场婚礼的要求。 分析: 2-sat问题。 代码: 阅读全文
posted @ 2019-01-18 21:41 MJT12044 阅读(164) 评论(0) 推荐(0)
摘要:Katu Puzzle 链接 题意: 有n个变量(每个变量只能是0或者1),m个等式,每个等式形如$x_i \ op \ x_j = c, \ op \in["and","or","xor"],c \in [0,1]$,问能否给n个变量赋值,满足所有等式。 分析: 2-sat问题。 注意一下a&b= 阅读全文
posted @ 2019-01-18 18:47 MJT12044 阅读(159) 评论(0) 推荐(0)
摘要:Find the Winning Move 链接 题意: 4*4的棋盘,给出一个初始局面,问先手有没有必胜策略? 有的话输出第一步下在哪里,如果有多个,按(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1) ... 的顺序输出第一个。没有输出“#####”。 阅读全文
posted @ 2018-06-28 21:56 MJT12044 阅读(296) 评论(0) 推荐(0)
摘要:1743:Musical Theme 链接 题意 给一个序列,找两个子串,满足: 长度至少为5 相同或者转置后相同(转置:序列每个数字加减相同的数字后变成的序列) 两个子串不能有公共部分。 思路 对于第二个条件,就是差分后相同(奇妙的转化)。那么就是求一个串的出现2次,不可重叠的最长的子串。 后缀数 阅读全文
posted @ 2018-05-04 11:15 MJT12044 阅读(206) 评论(0) 推荐(0)
摘要:POJ 2774 Long Long Message 链接 题意 求两个串最长公共子串。 思路 后缀数组:把两个串接在一起,求后缀数组和height,扫一遍即可。 height是后缀数组排序后的排名相邻的两个串的公共前缀,那么两个串的最长公共子串一定是:两个排名相邻的串的公共前缀,(不能是不相邻的, 阅读全文
posted @ 2018-05-04 07:55 MJT12044 阅读(165) 评论(0) 推荐(0)
摘要:链接 题意: n+1个点,求从0开始,走完所有的点,再回到0号点的最小距离。 思路 状压dp。首先Floyd预处理出任意两个点之间的距离。dp[s][i]表示走过的点的状态是s,其中到达i点的最小距离(i点属于走过的点,即s状态下的点)。当然s是二进制数1表示走过,0表示为走过。 那么dp[s][i 阅读全文
posted @ 2018-04-28 10:51 MJT12044 阅读(119) 评论(0) 推荐(0)
摘要:链接 思路 状压dp,dp[i][j]:表示到第i行,状态为j的方案数。预处理出每一行所有的可能的选法。 转移方程:dp[i][j] += d[i-1][k],j与k不冲突。 代码 http://poj.org/problem?id=3254 阅读全文
posted @ 2018-04-27 22:00 MJT12044 阅读(138) 评论(0) 推荐(0)
摘要:题目链接 字符串hash判断字符串是否相等。 code 阅读全文
posted @ 2018-03-23 07:32 MJT12044 阅读(158) 评论(0) 推荐(0)
摘要:Guardian of Decency Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 6133 Accepted: 2555 Description Frank N. Stein is a very conservative h 阅读全文
posted @ 2018-03-13 17:15 MJT12044 阅读(176) 评论(0) 推荐(0)
摘要:Paratroopers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8954 Accepted: 2702 Description It is year 2500 A.D. and there is a terrible w 阅读全文
posted @ 2018-03-11 18:12 MJT12044 阅读(176) 评论(0) 推荐(0)
摘要:Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 24789 Accepted: 13439 Description Bessie wants to navigate her spaceship through 阅读全文
posted @ 2018-03-11 17:21 MJT12044 阅读(196) 评论(0) 推荐(0)
摘要:Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15067 Accepted: 5263 Description In a certain course, you take n tests. If y 阅读全文
posted @ 2018-03-03 21:00 MJT12044 阅读(229) 评论(0) 推荐(0)
摘要:Cutting Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4806 Accepted: 1760 Description Urej loves to play various types of dull games 阅读全文
posted @ 2018-02-28 09:29 MJT12044 阅读(272) 评论(0) 推荐(0)
摘要:Necklace of Beads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8976 Accepted: 3722 Description Beads of red, blue or green colors are co 阅读全文
posted @ 2018-02-06 19:54 MJT12044 阅读(169) 评论(0) 推荐(1)
摘要:Tree Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u 阅读全文
posted @ 2017-12-30 21:26 MJT12044 阅读(173) 评论(1) 推荐(0)
摘要:Dining Description Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others. Farmer John h 阅读全文
posted @ 2017-12-23 16:40 MJT12044 阅读(195) 评论(0) 推荐(0)
摘要:Tunnel Warfare Description During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Pla 阅读全文
posted @ 2017-12-09 21:52 MJT12044 阅读(328) 评论(0) 推荐(0)
摘要:Godfather Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7885 Accepted: 2786 Description Last years Chicago was full of gangster fights an 阅读全文
posted @ 2017-11-26 10:31 MJT12044 阅读(310) 评论(0) 推荐(0)
摘要:Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 6361 Accepted: 3113 Case Time Limit: 2000MS Special Judge Description Ivan 阅读全文
posted @ 2017-11-05 19:45 MJT12044 阅读(162) 评论(0) 推荐(0)
摘要:Cow Marathon Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 5496 Accepted: 2685 Case Time Limit: 1000MS Description After hearing about th 阅读全文
posted @ 2017-08-15 19:28 MJT12044 阅读(285) 评论(0) 推荐(0)