1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UNICORNプログラミングコンテスト2021(AtCoder Beginner Contest 225) 参戦記

Posted at

UNICORNプログラミングコンテスト2021(AtCoder Beginner Contest 225) 参戦記

ABC225A - Distinct Strings

2分半で突破. 最大で6種類しかないので、サクッと生成してしまうのが良いですね.

S = input()

t = set()
t.add(S[0] + S[1] + S[2])
t.add(S[0] + S[2] + S[1])
t.add(S[1] + S[0] + S[2])
t.add(S[1] + S[2] + S[0])
t.add(S[2] + S[0] + S[1])
t.add(S[2] + S[1] + S[0])
print(len(t))

ABC225B - Star or Not

4分で突破. 全てのiについて*aibi*のどちらかに特定の数字が入っているかどうかですね.

from sys import setrecursionlimit, stdin

readline = stdin.readline
setrecursionlimit(10 ** 6)

N = int(readline())
ab = [list(map(int, readline().split())) for _ in range(N - 1)]

x = ab[0][0]
if all(x in l for l in ab):
    print('Yes')
    exit()
x = ab[0][1]
if all(x in l for l in ab):
    print('Yes')
    exit()
print('No')

ABC225C - Calendar Validator

12分半で突破、WA1. 7の倍数は右端でしか出ないことをチェックし漏れていましたね…….

from sys import setrecursionlimit, stdin

readline = stdin.readline
setrecursionlimit(10 ** 6)

N, M = map(int, readline().split())
B = [list(map(int, readline().split())) for _ in range(N)]

x = B[0][0]
for i in range(N):
    if (B[i][0] - 1) // 7 != (B[i][M - 1] - 1) // 7:
            print('No')
            exit()
    for j in range(M):
        if x + 7 * i + j != B[i][j]:
            print('No')
            exit()
print('Yes')

ABC225D - Play Train

36分半で突破. Doubly linked list で管理するだけみたいな簡単な問題じゃないよなあと思いつつ、計算量を見積もったらそれだけの簡単な問題でアレってなった.

from sys import stdin

readline = stdin.readline

N, Q = map(int, readline().split())

front = [0] * (N + 1)
rear = [0] * (N + 1)
result = []
for _ in range(Q):
    s = readline()
    if s[0] == '1':
        _, x, y = map(int, s.split())
        rear[x] = y
        front[y] = x
    elif s[0] == '2':
        _, x, y = map(int, s.split())
        rear[x] = 0
        front[y] = 0
    elif s[0] == '3':
        _, x = map(int, s.split())
        while front[x] != 0:
            x = front[x]
        t = []
        while True:
            t.append(x)
            if rear[x] == 0:
                break
            x = rear[x]
        result.append(' '.join(str(x) for x in [len(t)] + t))
print(*result, sep='\n')
1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?