Новые задачи!

This commit is contained in:
2017-10-05 17:00:44 +03:00
parent 426cbe6861
commit 07b1c4e0e1
3 changed files with 123 additions and 0 deletions

8
uts/uts_17_aut_py/3/G.py Normal file
View File

@@ -0,0 +1,8 @@
n = int(input()) # Unfinished
mas = input().split()
cnt = 0
for i in range(n):
curstr = str(*mas[:n] + mas[n:])
if curstr == curstr[::-1]:
cnt += 1
print(cnt)

View File

@@ -0,0 +1,36 @@
import sys
sys.stdin=open('die.in','r')
sys.stdout=open('die.out','w')
def d(a):
a[0],a[1],a[4],a[5]=a[4],a[5],a[1],a[0]
return a
def l(a):
a[0],a[1],a[2],a[3]=a[3],a[2],a[0],a[1]
return a
def r(a):
a[0],a[1],a[2],a[3]=a[2],a[3],a[1],a[0]
return a
def u(a):
a[0],a[1],a[4],a[5]=a[5],a[4],a[0],a[1]
return a
b=[[1, 6, 2, 5, 3, 4], [1, 6, 2, 5, 4, 3], [1, 6, 3, 4, 2, 5], [1, 6, 3, 4, 5, 2], [1, 6, 4, 3, 2, 5], [1, 6, 4, 3, 5, 2], [1, 6, 5, 2, 3, 4], [1, 6, 5, 2, 4, 3], [2, 5, 1, 6, 3, 4], [2, 5, 1, 6, 4, 3], [2, 5, 3, 4, 1, 6], [2, 5, 3, 4, 6, 1], [2, 5, 4, 3, 1, 6], [2, 5, 4, 3, 6, 1], [2, 5, 6, 1, 3, 4], [2, 5, 6, 1, 4, 3], [3, 4, 1, 6, 2, 5], [3, 4, 1, 6, 5, 2], [3, 4, 2, 5, 1, 6], [3, 4, 2, 5, 6, 1], [3, 4, 5, 2, 1, 6], [3, 4, 5, 2, 6, 1], [3, 4, 6, 1, 2, 5], [3, 4, 6, 1, 5, 2], [4, 3, 1, 6, 2, 5], [4, 3, 1, 6, 5, 2], [4, 3, 2, 5, 1, 6], [4, 3, 2, 5, 6, 1], [4, 3, 5, 2, 1, 6], [4, 3, 5, 2, 6, 1], [4, 3, 6, 1, 2, 5], [4, 3, 6, 1, 5, 2], [5, 2, 1, 6, 3, 4], [5, 2, 1, 6, 4, 3], [5, 2, 3, 4, 1, 6], [5, 2, 3, 4, 6, 1], [5, 2, 4, 3, 1, 6], [5, 2, 4, 3, 6, 1], [5, 2, 6, 1, 3, 4], [5, 2, 6, 1, 4, 3], [6, 1, 2, 5, 3, 4], [6, 1, 2, 5, 4, 3], [6, 1, 3, 4, 2, 5], [6, 1, 3, 4, 5, 2], [6, 1, 4, 3, 2, 5], [6, 1, 4, 3, 5, 2], [6, 1, 5, 2, 3, 4], [6, 1, 5, 2, 4, 3]]
s=input()
mans=10000000
bans=0
for j in b:
x=0
for i in s:
if i=='D':
j=d(j)
elif i=='L':
j=l(j)
elif i=='R':
j=r(j)
else:
j=u(j)
x+=j[0]
if x>bans:
bans=x+0
if x<mans:
mans=x+0
print(mans,bans)

View File

@@ -0,0 +1,79 @@
import sys
import math
sys.stdin=open('storage.in','r')
sys.stdout=open('storage.out','w')
def NEPALUS(s,n):
if s=='0':
if n==1:
return 1
elif n==2:
return 2
else:
return 4
elif s=='1':
if n==2:
return 3
elif n==0:
return 5
elif s=='2':
if n==1:
return 3
elif n==0:
return 6
elif s=='4':
if n==1:
return 5
elif n==2:
return 6
else:
return 7
def VASHE(s,n):
if s=='1' and n!=1 or s=='2' and n!=2 or s=='4' and n!=0 or s=='3' and n==0 or s=='5' and n==2 or s=='6' and n==1:
return s
if s=='3':
if n==1:
return 2
elif n==2:
return 1
elif s=='5':
if n==1:
return 4
elif n==0:
return 1
elif s=='6':
if n==2:
return 4
elif n==0:
return 2
elif s=='7':
if n==1:
return 6
elif n==2:
return 5
elif n==0:
return 3
else:
return 0
n,m=map(int,input().split())
c=math.ceil(n/3)
a={}
for i in range(m):
q=list(map(str,input().split()))
if q[0]=='Login':
a[q[1]]='0'*c
elif q[0]=='Completed':
q[2]=int(q[2])
if q[2]==0:
pass
else:
l=(q[2]-1)//3
a[q[1]]=a[q[1]][:l]+str(NEPALUS(a[q[1]][l],q[2]%3))+a[q[1]][(l+1):]
elif q[0]=='Clear':
q[2]=int(q[2])
if q[2]==0:
pass
else:
l=(q[2]-1)//3
a[q[1]]=a[q[1]][:l]+str(VASHE(a[q[1]][l],q[2]%3))+a[q[1]][(l+1):]
else:
print(q[1],a[q[1]])