🐥

AtCoder ABC236 個人的メモ

2022/01/23に公開

A - chukodai

S = list(input())
a, b = map(lambda n: int(n) - 1, input().split())

S[a], S[b] = S[b], S[a]

print("".join(S))

B - Who is missingb

N = int(input())
A = list(map(int, input().split()))

cnt = [0] * (N + 1)
for a in A:
    cnt[a] += 1

print(cnt.index(3))

C - Route Map

N, M = map(int, input().split())
S = list(map(str, input().split()))
T = set(map(str, input().split()))

for s in S:
    if s in T:
        print("Yes")
    else:
        print("No")

D - Dance

https://atcoder.jp/contests/abc236/editorial/3285

N = int(input())
# A[i][j]で(i, j)の組の相性となるように入力Aを整形
A = [[0] * i + list(map(int, input().split())) for i in range(1, N * 2)]

ans = 0
# stackは(現在の排他的論理和, 未選択の番号)を要素とする
stack = [(0, set(range(N * 2)))]
while stack:
    B, remain_nums = stack.pop()
    if not remain_nums:
        ans = max(ans, B)
        continue

    i = min(remain_nums)
    remain_nums ^= {i}
    for j in remain_nums:
        stack.append((B ^ A[i][j], remain_nums ^ {j}))

print(ans)

Discussion