LPS hdoj 4745-Rabbits

Source: Internet
Author: User

Topic Portal

1 /*2 Test instructions: One rabbit jumps clockwise, the other jumps counterclockwise, and the weight of the stones is equal and cannot cross the starting point .3 LPs: This is the application of LPs, the ring multiplied into a chain, a set of LPS, but do not understand dp[i][i+n-2] + 1, see other people's problem-solving report, to later fill (play the game)4     Detailed explanation5 */6 /************************************************7 * Author:running_time8 * Created time:2015-8-8 16:57:239 * File Name:HDOJ_4747_LPS.cppTen  ************************************************/ One  A#include <cstdio> -#include <algorithm> -#include <iostream> the#include <sstream> -#include <cstring> -#include <cmath> -#include <string> +#include <vector> -#include <queue> +#include <deque> A#include <stack> at#include <list> -#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> in using namespacestd; -  to #defineLson L, Mid, RT << 1 + #defineRson mid + 1, R, RT << 1 | 1 -typedefLong Longll; the Const intMAXN = 2e3 +Ten; * Const intINF =0x3f3f3f3f; $ Const intMOD = 1e9 +7;Panax Notoginseng intA[MAXN], DP[MAXN][MAXN]; -  the  + intMainvoid)    {//hdoj 4745, rabbits A     intN; the      while(SCANF ("%d", &n) = =1)   { +         if(!n) Break; -          for(intI=1; i<=n; ++i) { $scanf ("%d", &a[i]); $A[i+n] =A[i]; -         } -Memset (DP,0,sizeof(DP)); the          for(intI=1; i<=2*n; ++i) Dp[i][i] =1; -          for(intI=2; i<2*n; ++i) {Wuyi              for(intj=1; j+i-1<=2*n; ++j) { the                 if(A[j] = = a[j+i-1]) dp[j][j+i-1] = dp[j+1][j+i-2] +2; -                 Else    { Wudp[j][j+i-1] = max (dp[j+1][j+i-1], dp[j][j+i-2]); -                 } About             } $         } -         intAns =0; -          for(intI=1; i<=n; ++i) { -ans = max (ans, dp[i][i+n-1]); Aans = max (ans, dp[i][i+n-2] +1); +         } theprintf ("%d\n", ans); -     } $  the     return 0; the}

LPS hdoj 4745-Rabbits

Related Keywords:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.