問題はこちら
3完
A
時間を使ってしまった
from collections import Counter S = list(input()) # 例としてCounter型を作成 my_counter = Counter(S) # 値が1であるキーを取得 keys_with_value_one = [key for key, value in my_counter.items() if value == 1] # print(keys_with_value_one) for i in range(len(S)): if S[i] == keys_with_value_one[0]: print(1+i)
B
N = int(input()) P = [0] + list(map(int, input().split())) Q = int(input()) # for q in range(Q): A,B = list(map(int, input().split())) id_A = [idx for idx, value in enumerate(P) if value == A][0] id_B = [idx for idx, value in enumerate(P) if value == B][0] # print(id_A, id_B) print(P[min(id_A, id_B)])
C
import string N = int(input()) S = input() Q = int(input()) #変換前のアルファベットa~z alphabet_before = string.ascii_lowercase #変換後のアルファベットa~z alphabet_after = string.ascii_lowercase for _ in range(Q): c,d = list(input().split()) alphabet_after = alphabet_after.replace(c,d) dict_alphabet = {alphabet_before[i] : alphabet_after[i] for i in range(len(alphabet_before))} # 与えられた文字列を1種類ずつ変換 result = "" for s in S: result += dict_alphabet[s] print(result)
D
E
F