PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 9ms RepoModel.GetById 0ms app.codeStats 0ms

/139C.py

https://bitbucket.org/alculquicondor/codeforces
Python | 42 lines | 39 code | 3 blank | 0 comment | 22 complexity | fafde55aa4e013529f3b892a0cf975e3 MD5 | raw file
 1k=0
 2
 3def isvowel(s):
 4	return s=='a' or s=='e' or s=='i' or s=='o' or s=='u'
 5
 6def qsch(A):
 7	for j in range(len(A)):
 8		x=A[j]
 9		i=len(x)-1
10		c=0
11		while i>=0:
12			if isvowel(x[i]):
13				c+=1
14			if(c==k):
15				break
16			i-=1
17		if(c<k):
18			return 'NO'
19		A[j]=x[i:]
20	if(A[0]==A[1]==A[2]==A[3]):
21		return 'aaaa'
22	if(A[0]==A[1] and A[2]==A[3]):
23		return 'aabb'
24	if(A[0]==A[2] and A[1]==A[3]):
25		return 'abab'
26	if(A[0]==A[3] and A[1]==A[2]):
27		return 'abba'
28	return 'NO'
29
30n,k=[int(x) for x in raw_input().split()]
31ans='aaaa'
32for i in range(n):
33	A=[]
34	for j in range(4):
35		A.append(raw_input())
36	tt=qsch(A)
37	if ans=='aaaa':
38		ans=tt
39	elif ans!=tt and tt!='aaaa':
40		ans='NO'
41		break
42print ans