有佬AC吗,我为啥dp就9%,调了一小时思路感觉没问题思路大概是分奇偶位,然后分别判断#滴滴#def main(): n, k = map(int, input().split()) cost = [0] * k st = 'abcdefghijklmnopqrstuvwxyz' for i in range(k): cost[i] = list(map(int, input().split())) s = input() dp = [0] * (n + 1) dp[2] = cost[st.index(s[0])][st.index(s[1])] for i in range(3, n + 1): if i & 1 == 1: dp[i] = max(dp[i - 1], dp[i - 2] + cost[st.index(s[i - 2])][st.index(s[i - 1])]) else: dp[i] = max(dp[i - 2] + cost[st.index(s[i - 2])][st.index(s[i - 1])], dp[i - 1] + cost[st.index(s[0])][st.index(s[i - 1])]) print(dp[-1]) if __name__ == "__main__": main()