-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsim.py
More file actions
32 lines (31 loc) · 721 Bytes
/
sim.py
File metadata and controls
32 lines (31 loc) · 721 Bytes
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
mod=10e9+7
class swap:
def case1(self,a,s):
for i in range(a[1],a[2]):
s[i]=a[3]
#return(s)
def case2(self,a,s):
for i in range(a[1],a[2]):
if(s[i]=="A"):
x=(a[3]-a[4]+mod)%mod
y=(a[3]+a[4])%mod
else:
x=(a[3]+a[4])%mod
y=(a[4]-a[3]+mod)%mod
a[3]=x
a[4]=y
def main():
t=int(input())
n=int(input())
s=input()
q=int(input())
cl=swap()
for i in range(q):
st=input().split()
print(st)
if(st[0]==1):
cl.case1(st,s)
else:
cl.case2(st,s)
print(str(a[3])+" "+str(a[4])+"\n")
main()