LPS HDOJ 4745 Two Rabbits】的更多相关文章

题目传送门 /* 题意:一只兔子顺时针跳,另一只逆时针跳,跳石头权值相等而且不能越过起点 LPS:这道就是LPS的应用,把环倍增成链,套一下LPS,然而并不能理解dp[i][i+n-2] + 1,看别人的解题报告吧,以后来补(玩游戏) 详细解释 */ /************************************************ * Author :Running_Time * Created Time :2015-8-8 16:57:23 * File Name :HDOJ…
Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 944    Accepted Submission(s): 496 Problem Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunn…
题目传送门 /* 模拟:看懂题意,主要是碰壁后的转向,笔误2次 */ #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; ; const int INF = 0x3f3f3f3f; struct Rabbit { char c; int d, s, t; int x, y; }r[]; int main(void) /…
Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 505    Accepted Submission(s): 260 Problem Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny…
题目链接: http://blog.csdn.net/scnu_jiechao/article/details/11759333 Two Rabbits Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others) 问题描述 Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoo…
Two Rabbits Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 1274 Accepted Submission(s): 641 Problem Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny aft…
http://acm.hdu.edu.cn/showproblem.php?pid=4745 题意: 有一个环,现在有两只兔子各从一个点开始起跳,一个沿顺时针,另一个沿逆时针,只能在一圈之内跳,并且每次所在的点的大小必须相同,问最多能经过 几个点. 思路:环状的话可以先倍增改成链. 这道题目的话就是求最长回文子串,它的求法是这样的: 设字符串为str,长度为n,p[i][j]表示第i到第j个字符间的子序列的个数(i<=j),则: 状态初始条件:dp[i][i]=1 (i=0:n-1) 状态转移方…
http://acm.hdu.edu.cn/showproblem.php?pid=4745 题意: 有两只兔子Tom Jerry, 他们在一个用石头围城的环形的路上跳, Tom只能顺时针跳,Jerry只能逆时针跳,  要求在跳的过程中他们所在石头的权值必须相同,而且只能单向跳,中间不能有已经跳过的石头. 思路: 模型就是求环上的最长回文串,我们只要将原串倍增,然后每个长度为n的子串的最长回文串就是我们要求的.区间DP一下就好了, 注意要考虑起点终点是统一点的情况特殊. //#pragma co…
Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoon, they planned to play a game with some stones. There were n stones on the ground and they were arranged as a clockwise ring. That is to say, the firs…
思路:求最长回文子串的长度!代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> using namespace std; ],dp[][]; int dfs(int p,int q) { ) return dp[p][q]; ; dp[p][q]=max(df…