-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf_1379_a.py
61 lines (60 loc) · 1.18 KB
/
cf_1379_a.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
t = int(input())
for i in range(t):
l = int(input())
s = input()
if 'abacaba' in s:
if 'abacaba' in s[s.index('abacaba') + 1:]:
print('NO')
else:
print('YES')
print(s.replace('?', 'z'))
else:
for i in range(l - 6):
p = True
for a, b in zip(s[i:i+7], 'abacaba'):
if not a in [b, '?']:
p = False
break
if p:
r = s.replace('?', 'z')
r = r[:i] + 'abacaba' + r[i+7:]
if 'abacaba' in r and not 'abacaba' in r[r.index('abacaba') + 1:]:
print('YES')
print(r)
break
else:
p = False
if not p:
print('NO')
# for _ in range(int(input())):
# n = int(input())
# s = input()
# ss="abacaba"
# c=0
# ns=[]
# for i in range(1,len(s)+1):
# if s[i-1]== '?':
# if s[i-2]=='a':
# ns.append('d')
# else:
# ns.append(ss[c])
# else:
# ns.append(s[i-1])
# c += 1
# if c==len(ss):
# c=0
#
#
#
#
# fs =''.join([str(i) for i in ns])
# x = fs.count(ss)
# c1 = fs.find(ss)
# c2 = fs.rfind(ss)
#
#
# if x==1 and c1==c2:
# print("Yes")
# print(fs)
# else:
# print("No")