Skip to content

Commit

Permalink
February Challenge 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypotter0 committed Feb 8, 2018
1 parent 07c0d4d commit 35c4f16
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CP/ February Challenge 2018/prob1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import re

for _ in range(int(input())):
c = 0
s = raw_input()
pattern = ['c','h','e','f']
# s = ''.join([i for i in s if i.isalpha()])
# s = s.lower()
for i in range(len(s)-3) :
if(s[i] in pattern and s[i+1] in pattern and s[i+2] in pattern and s[i+3] in pattern and s[i]!=s[i+1] and s[i]!=s[i+2] and s[i]!=s[i+3] and s[i+1]!=s[i+2]):
if(s[i+1]!=s[i+3] and s[i+2]!=s[i+3]):
c+=1
# print(s[i]+s[i+1]+s[i+2]+s[i+3])
if(c>0):
print "lovely",c
else :
print "normal"
29 changes: 29 additions & 0 deletions CP/ February Challenge 2018/prob2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import re
for _ in range(int(input())):
n,m,x,k= map(int,raw_input().split())
string = raw_input()
oddp,evenp = 0,0
for i in range(int(len(string))):
if(string[i]=='O'):
oddp+=1
else:
evenp+=1
if(m*x<n or n>k):
print("no")
continue
# if(m==1 and not(re.search('O',string))):
# print("no")
# continue
# # print(re.search('O',string))
evenpm = m/2
oddpm = m%2 + m/2
evenp = (evenp/x)*x
oddp = (oddp/x)*x
e = min(evenp,evenpm*x)
o = min(oddp,oddpm*x)
# print(evenp,evenpm,oddp,oddpm,e,o)
summ = e+o
if(summ>=n):
print("yes")
else :
print("no")
47 changes: 47 additions & 0 deletions CP/Tessellathon/prob1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Max=5001;

vector<ll> adj[Max];
bool mark[Max];

bool dfsrec(ll cur,ll s,ll k)
{
if(k==0&&cur==s) return true;
if(k==0) return false;
if(mark[cur]) return false;
mark[cur]=true;
bool state=false;
ll ss=adj[cur].size();
for(ll i=0;i<ss;i++)
{
if(dfsrec(adj[cur][i],s,k-1)) {state=true;break;}
}
mark[cur]=false;
return state;
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n,m,i,j,k,u,v;
cin>>n>>m;
bool flg=false;
for(i=0;i<m;i++)
{
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for(i=1;i<=n;i++)
{
memset(mark,0,sizeof mark);
if(dfsrec(i,i,4)) {flg=true;break;}
}
if(flg) cout<<"Yes";
else cout<<"No";
return 0;
}

0 comments on commit 35c4f16

Please sign in to comment.