LeetCode T17 ++ The 14th ACM College Student Programming Contest (Synchronous Competition) of Guangzhou University TA TB

Insert picture description here

class Solution:
    def letterCombinations(self, digits):
    
        d = dict()
        d["2"] = ['a','b','c',]
        d["3"] = ['d','e','f',]
        d["4"] = ['g','h','i',]
        d["5"] = ['j','k','l',]
        d["6"] = ['m','n','o',]
        d["7"] = ['p','q','r','s']
        d["8"] = ['t','u','v',]
        d["9"] = ['w','x','y','z']
        n = len(digits)
        if n==0:
            return []
        count = 1
        final = d[digits[0]]
        while(count < n):
            temp = []
            for f in final:
        
                for ch in d[digits[count]]:
                    temp.append(f+ch)
            final = temp
            count +=1

        return final

Insert picture description here
Insert picture description here
Insert picture description here

d = dict()
d["left Walk"] = "left"
d["right Walk"] = "right"
d["QuickDrop"] = "down"
d["Squat"] = "down"
d["leftup Dash"] = "left up X"

d["up Dash"] = "up X"

d["rightup Dash"] = "right up X"

d["left Dash"] = "left X"

d["right Dash"] = "right X"

d["leftdown Dash"] = "left down X"

d["down Dash"] = "down X"

d["rightdown Dash"] = "right down X"

d["Grasp"] = "Z"
d["Jump"] = "C"

num = int(input())
s_t = [""]*num
for i in range(num):
    s_t[i] = input()
for t in s_t:
    print(d[t])

Insert picture description here
Insert picture description here

n = int(input())
k = int(input())
string = [''] * n

for i in range(n):
    string[i] = input()

x = 0
y = 0
M = []
M.append([x,y])
for i in string:
    print(i)
    if i=='L':
        x -= 1
        M.append([x,y])
    elif i=='R':
        x += 1
        M.append([x,y])
    elif i=='U':
        y += 1
        M.append([x,y])
    elif i=='D':
        y -= 1
        M.append([x,y])
    else:
        M.append([x,y])
flag = True
for i in range(k+1):
    if M[k+i] == M[i]:
        flag = False
        print("no")
        break
if flag:
    print("yes")

Insert picture description here

Guess you like

Origin blog.csdn.net/wjl__ai__/article/details/112055450
Recommended