hirohirohirohirosのブログ

地方国立大学に通う情報系学部4年

Atcoder ABC244 振り返り

A - Last Letter【AC】

 言われたとおりにやります.

N= input()
print(input()[-1])
B - Go Straight and Turn Right【AC】

 N<=10^5なので,1回ずつシミュレーションしても十分間に合います.

N = input()
T = input()

step = [(1, 0), (0, -1), (-1, 0), (0, 1)]
now = 0
pos = [0, 0]
for t in T:
    if t == "S":
        pos[0] += step[now][0]
        pos[1] += step[now][1]
    else:
        now += 1
        now %= 4
print(*pos)
C - Yamanote Line Game【AC】

 初めてインタラクティブ形式の問題を見ました."flush=Trueを入れる"というところを気をつけておけば後は普通のプログラミングでいいのかなと感じました.

N = int(input())
lis = [i for i in range(1 ,2*N+2)]
for _ in range(2*N+1):
    ans = lis.pop()
    print(ans, flush=True)
    if len(lis) == 0:
        break
    val = int(input())
    lis.remove(val)
D - Swap Hats【AC】

 与えられる文字はRGBの3で固定で,文字がダブる事もないので,取り得るパターンは6通りです.R G Bという文字の並びを1回以上入れ替えて,再びR G Bに戻すという処理をするとき,処理の回数は必ず偶数回になるはずです(根拠無し).よってSとTで文字が2字異なっている場合,その2字を入れ替えて残り10^18-1回,偶数回でしか元に戻せないので必ず失敗します.逆に,全ての文字が同じだったり,全ての文字が異なっている場合,偶数回でTになるので,10^18回目でも必ずTになります.

S1, S2, S3 = input().split()
T1, T2, T3 = input().split()

if S1 == T1 and S2 == T2 and S3 == T3:
    print("Yes")
elif S1 == T1 or S2 == T2 or S3 == T3:
    print("No")
else:
    print("Yes")