LoginSignup
0
0

from ABC291 to ABC300 (A, B)

Last updated at Posted at 2023-08-10

はじめに

備忘録ではありますが、解法や変数名、書式にはこだわっています。
よりよい書き方があればご指摘ください。
Python独自の文法も、読みやすさを優先しながら使用します。

A

ABC291

s = input()

for i, char in enumerate(s):
    if "A" <= char <= "Z":
        print(i + 1)

ABC292

print(input().upper())

ABC293

s = list(input())

# (0, 1), (2, 3), (4, 5) …
for i in range(len(s) // 2):
    s[2 * i], s[2 * i + 1] = s[2 * i + 1], s[2 * i]

print(*s, sep="")

ABC294

_ = input()
a = [int(i) for i in input().split()]

for number in a:
    if number % 2 == 0:
        print(number, end=" ")

ABC295

_ = input()
w = input().split()

for word in w:
    if word in ["and", "not", "that", "the", "you"]:
        print("Yes")
        break
else:
    print("No")

ABC296

n = int(input())
s = input()

for i in range(n - 1):
    if s[i] == s[i + 1]:
        print("No")
        break
else:
    print("Yes")

ABC297

n, d = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]

for i in range(n - 1):
    if t[i + 1] - t[i] <= d:
        print(t[i + 1])
        break
else:
    print(-1)

ABC298

_ = input()
s = input()

is_passed = False
for evaluation in s:
    # 条件1
    if evaluation == "o":
        is_passed = True
        continue

    # 条件2
    if evaluation == "x":
        print("No")
        break
else:
    if is_passed:
        print("Yes")
    # 全て「-」の場合
    else:
        print("No")
_ = input()
s = input()

if "o" in s and "x" not in s:
    print("Yes")
else:
    print("No")

ABC299

_ = input()
s = input()

if s.find("|") < s.find("*") < s.rfind("|"):
    print("in")
else:
    print("out")

ABC300

n, a, b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

for i in range(n):
    if a + b == c[i]:
        print(i + 1)
_, a, b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

print(c.index(a + b) + 1)

B

ABC291

n = int(input())
x = [int(i) for i in input().split()]

print(sum(sorted(x)[n:-n]) / (3 * n))

ABC292

n, q = [int(i) for i in input().split()]

players = [0] * n
for _ in range(q):
    event = [int(i) for i in input().split()]

    if event[0] in [1, 2]:
        players[event[1] - 1] += event[0]
    else:
        if 2 <= players[event[1] - 1]:
            print("Yes")
        else:
            print("No")

ABC293

n = int(input())
a = [int(i) for i in input().split()]

call = [False] * n
for i in range(n):
    if not call[i]:
        call[a[i] - 1] = True

print(call.count(False))
for i in range(n):
    if not call[i]:
        print(i + 1, end=" ")

ABC294

h, w = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for _ in range(h)]

uppercase = ["."] + [chr(ord("A") + i) for i in range(26)]
for i in range(h):
    for j in range(w):
        a[i][j] = uppercase[a[i][j]]

for elem in a:
    print(*elem, sep="")

ABC295

r, c = [int(i) for i in input().split()]
b = [list(input()) for _ in range(r)]

for i in range(r):
    for j in range(c):
        # 爆弾以外はスキップ
        if not b[i][j].isdigit():
            continue

        for k in range(r):
            for l in range(c):
                # 同時に爆発するため、周りの爆弾を巻き込まない
                if b[k][l].isdigit():
                    continue
                if abs(i - k) + abs(j - l) <= int(b[i][j]):
                    b[k][l] = "."

        # 自らも爆発する
        b[i][j] = "."

for elem in b:
    print(*elem, sep="")

ABC296

s = [list(input()) for _ in range(8)]

for i in range(8):
    for j in range(8):
        if s[i][j] == "*":
            print("abcdefgh"[j], 8 - i, sep="")

ABC297

s = input()

c1 = (s.find("B") - s.rfind("B")) % 2
c2 = s.find("R") < s.find("K") < s.rfind("R")

print("Yes" if c1 and c2 else "No")

ABC298

from copy import deepcopy

n = int(input())
a = [[int(i) for i in input().split()] for _ in range(n)]
b = [[int(i) for i in input().split()] for _ in range(n)]

for _ in range(4):

    # 二重ループだと for-else は使えない
    flag = True
    for j in range(n):
        for k in range(n):
            if a[j][k] and not b[j][k]:
                flag = False
    if flag:
        print("Yes")
        break

    a_deepcopy = deepcopy(a)
    for r in range(n):
        for c in range(n):
            # ABC307_B
            a[r][c] = a_deepcopy[n - c - 1][r]
else:
    print("No")

ABC299

n, t = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]

# 方法2
if t not in c:
    t = c[0]

# ABC275_A, ABC304_A
index = c.index(t)
for i in range(n):
    if c[i] == t and r[index] < r[i]:
        index = i

print(index + 1)

ABC300

h, w = [int(i) for i in input().split()]
a = [list(input()) for _ in range(h)]
b = [list(input()) for _ in range(h)]

for s in range(h):
    for t in range(w):

        flag = True
        for r in range(h):
            for c in range(w):
                # ABC304_A
                if a[(r + s) % h][(c + t) % w] != b[r][c]:
                    flag = False
        if flag:
            print("Yes")
            exit()

print("No")
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0