From cb9f0ddd0d69bdcf0ac9ff415342232ef0f426cc Mon Sep 17 00:00:00 2001 From: harrypotter0 <9654263057akashkandpal@gmail.com> Date: Thu, 22 Feb 2018 07:45:35 +0530 Subject: [PATCH] CSUBSEQ --- CP/000-Templates/temp.cpp | 31 ++++++++ .../prob3.cpp => 000-Templates/temp.py} | 0 CP/Codemania/prob6.cpp | 3 + CP/Codemania/prob7.cpp | 0 CP/February Cook-Off 2018/prob3.py | 11 +++ CP/February Cook-Off 2018/prob4.cpp | 73 +++++++++++++++++++ 6 files changed, 118 insertions(+) create mode 100644 CP/000-Templates/temp.cpp rename CP/{February Cook-Off 2018/prob3.cpp => 000-Templates/temp.py} (100%) create mode 100644 CP/Codemania/prob7.cpp create mode 100644 CP/February Cook-Off 2018/prob3.py diff --git a/CP/000-Templates/temp.cpp b/CP/000-Templates/temp.cpp new file mode 100644 index 0000000..e6947d8 --- /dev/null +++ b/CP/000-Templates/temp.cpp @@ -0,0 +1,31 @@ +#include +// #ifdef DEMETRIO +// #define deb(...) fprintf(stderr,__VA_ARGS__) +// #define deb1(x) cerr << #x << " = " << x << endl +// #else +// #define deb(...) 0 +// #define deb1(x) 0 +// #endif +#define pb push_back +#define mp make_pair +#define fst first +#define snd second +#define fore(i,a,b) for(int i=a,ThxDem=b;i=x: + cnt+=1 + x=(a[i]*k)+b + print cnt+1 diff --git a/CP/February Cook-Off 2018/prob4.cpp b/CP/February Cook-Off 2018/prob4.cpp index e69de29..986dd2a 100644 --- a/CP/February Cook-Off 2018/prob4.cpp +++ b/CP/February Cook-Off 2018/prob4.cpp @@ -0,0 +1,73 @@ +#include +using namespace std; +const int inf = 1e9; + +inline void upd(int &a, int b) { + a = max(a, b); +} + + +void solve(){ + int n,k,arr[35][35][35][35]; + cin>>k>>k; + for(int i=0;i<=k+1;i++)for(int j=0;j<=k+1;j++) + for(int l=0;l<=k+1;l++)for(int s=0;s<=k+1;s++) + arr[i][j][l][s]= -1e9; + + arr[0][0][0][0]=0; + + string st; + cin>>st; + + for(auto c:st) + for(int i=k+1;i>=0;i--)for(int j=k+1;j>=0;j--) + for(int l=k+1;l>=0;l--)for(int s=k;s>=0;s--){ + if(c=='c'){ + upd(arr[min(i+1,k+1)][j][l][s],arr[i][j][l][s]+1); + }else + if(c=='h'){ + upd(arr[i][min(i+j,k+1)][l][s],arr[i][j][l][s]+1); + }else + if(c=='e'){ + upd(arr[i][j][min(j+l,k+1)][s],arr[i][j][l][s]+1); + }else + if(s+l<=k){ + upd(arr[i][j][l][s+l],arr[i][j][l][s]+1); + } + } + + int res=0; + for (int i=0;i<=k+1;i++) for (int j=0;j<=k+1;j++) + for (int l=0;l<=k+1;l++){ + // if (arr[i][j][l][k]!=-1e9) + upd(res,arr[i][j][l][k]); + } + if (res==0) + cout<<-1<<'\n'; + else + cout<>t; + while(t--){ + solve(); + } +} +/* + +5 +7 3 +chehefc +8 4 +chehefch +19 24 +ccccchhhhheeeeeffff +20 5 +echhhfhfcecfhechfcch +99 27 +ffhffhffcfechchccccfhhhfhhhhhhehhhehhhhheeeeefeeeeeeheeheeeeffcfffffffffffhffffchffeffcefefhhfcehfe + +*/