Skip to content

Commit

Permalink
CSUBSEQ
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypotter0 committed Feb 22, 2018
1 parent bd60a07 commit cb9f0dd
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 0 deletions.
31 changes: 31 additions & 0 deletions CP/000-Templates/temp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <bits/stdc++.h>
// #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<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcopy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n,k;char s[512];
int f[33][33][33][33];

void upd(int& a, int v){a=max(a,v);}

int main(){
int tn;
scanf("%d",&tn);
while(tn--){
}
return 0;
}
File renamed without changes.
3 changes: 3 additions & 0 deletions CP/Codemania/prob6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ int main(){
adj[n+i].push_back(neg(i));
adj[i].push_back(neg(n+i));
}
for(i=1;i<=n;i++){
cout<<adj[i]<<" ";
}
for(i=1;i<=m;i++){
scanf("%d%d",&a,&b);
adj[neg(a)].push_back(b);
Expand Down
Empty file added CP/Codemania/prob7.cpp
Empty file.
11 changes: 11 additions & 0 deletions CP/February Cook-Off 2018/prob3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
for _ in range(int(raw_input())):
n,k,b=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
x=(a[0]*k)+b
cnt=0
for i in range(1,n):
if a[i]>=x:
cnt+=1
x=(a[i]*k)+b
print cnt+1
73 changes: 73 additions & 0 deletions CP/February Cook-Off 2018/prob4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include<bits/stdc++.h>
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<<st.size()-res<<'\n';

}

int main(){
int t;
cin>>t;
while(t--){
solve();
}
}
/*
5
7 3
chehefc
8 4
chehefch
19 24
ccccchhhhheeeeeffff
20 5
echhhfhfcecfhechfcch
99 27
ffhffhffcfechchccccfhhhfhhhhhhehhhehhhhheeeeefeeeeeeheeheeeeffcfffffffffffhffffchffeffcefefhhfcehfe
*/

0 comments on commit cb9f0dd

Please sign in to comment.