From ca6c8b864716330443a75b5d2e75ca609f96b77c Mon Sep 17 00:00:00 2001 From: ramjeet saran Date: Sun, 27 Sep 2015 22:52:00 +0530 Subject: [PATCH] AIBOHP haha palindrome not LCS --- AIBOHP.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Readme | 1 + 2 files changed, 65 insertions(+) create mode 100644 AIBOHP.cpp diff --git a/AIBOHP.cpp b/AIBOHP.cpp new file mode 100644 index 0000000..31242ad --- /dev/null +++ b/AIBOHP.cpp @@ -0,0 +1,64 @@ +//DATE: 27/09/2015 +//Author: Ramjeet Saran +//http://www.spoj.com/problems/AIBOHP/ + +#include + +#define gc getchar_unlocked +#define pc putchar_unlocked +# define MAX(a,b) a>b ? a : b; +# define MIN(a,b) a=0) + pc(snum[i--]); + pc('\n'); +} + +int compute(string IN){ + + int len = IN.length(); + for(int i = 0; i <= len; i++) { + for(int j = 0; j <= len; j++) { + if (i == 0 || j == 0) + DP[i][j] = 0; + else { + if(IN[i - 1] == IN[len - j]) + DP[i][j] = DP[i - 1][j - 1] + 1; + else + DP[i][j] = MAX(DP[i][j - 1], DP[i - 1][j]); + } + //cout<>T; + while(T--){ + cin>>B; + fastwrite(compute(B)); + } +} diff --git a/Readme b/Readme index f327d4e..d6b701b 100644 --- a/Readme +++ b/Readme @@ -72,3 +72,4 @@ http://www.spoj.com/users/raj94/ 68) MIXTURES 69) GCD2 70) ANARC09A +71) AIBOHP