前回の振り返り
今日はABC開催日だったので参加結果を振り返る
https://atcoder.jp/contests/abc402
今週はA,B,Cの3完(0ペナ)
A
内包記法でフィルターする
ソースコード
main.py
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, Counter, deque
from functools import reduce, lru_cache
from itertools import product, accumulate, groupby, combinations
import sys
import os
def rI(): return int(sys.stdin.readline().rstrip())
def rLI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def rI1(): return (int(sys.stdin.readline().rstrip())-1)
def rLI1(): return list(map(lambda a:int(a)-1,sys.stdin.readline().rstrip().split()))
def rS(): return sys.stdin.readline().rstrip()
def rLS(): return list(sys.stdin.readline().rstrip().split())
IS_LOCAL = int(os.getenv("ATCODER", "0"))==0
err = (lambda *args, **kwargs: print(*args, **kwargs, file=sys.stderr)) if IS_LOCAL else (lambda *args, **kwargs: None)
def main():
S = rS()
ans = [s for s in S if ord("A") <= ord(s) <= ord("Z")]
print("".join(ans))
if __name__ == '__main__':
main()
B
queueを使った練習問題ですね。
ソースコード
main.py
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, Counter, deque
from functools import reduce, lru_cache
from itertools import product, accumulate, groupby, combinations
import sys
import os
def rI(): return int(sys.stdin.readline().rstrip())
def rLI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def rI1(): return (int(sys.stdin.readline().rstrip())-1)
def rLI1(): return list(map(lambda a:int(a)-1,sys.stdin.readline().rstrip().split()))
def rS(): return sys.stdin.readline().rstrip()
def rLS(): return list(sys.stdin.readline().rstrip().split())
IS_LOCAL = int(os.getenv("ATCODER", "0"))==0
err = (lambda *args, **kwargs: print(*args, **kwargs, file=sys.stderr)) if IS_LOCAL else (lambda *args, **kwargs: None)
def main():
Q = rI()
q = deque()
for _ in range(Q):
query = rLI()
if query[0] == 1:
q.append(query[1])
elif query[0] == 2:
print(q.popleft())
if __name__ == '__main__':
main()
C
入っている食材をキーにした配列を用意して
克服した食材をそれぞれの料理に除外する。
簡略化のために数だけを操作する。
0になったらすべて克服したので加算
ソースコード
main.py
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, Counter, deque
from functools import reduce, lru_cache
from itertools import product, accumulate, groupby, combinations
import sys
import os
def rI(): return int(sys.stdin.readline().rstrip())
def rLI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def rI1(): return (int(sys.stdin.readline().rstrip())-1)
def rLI1(): return list(map(lambda a:int(a)-1,sys.stdin.readline().rstrip().split()))
def rS(): return sys.stdin.readline().rstrip()
def rLS(): return list(sys.stdin.readline().rstrip().split())
IS_LOCAL = int(os.getenv("ATCODER", "0"))==0
err = (lambda *args, **kwargs: print(*args, **kwargs, file=sys.stderr)) if IS_LOCAL else (lambda *args, **kwargs: None)
def main():
N, M = rLI()
# S = rS()
# A = []
K = []
Bi = defaultdict(list)
for i in range(M):
k, *a = rLI()
K.append(k)
# A.append(set(a))
for c in a:
Bi[c].append(i)
B = rLI()
ans = 0
for b in B:
for i in Bi[b]:
# A[i].remove(b)
K[i] -= 1
if K[i] == 0:
ans += 1
print(ans)
if __name__ == '__main__':
main()
D
幾何的な問題はすぐ飛ばしちゃう
E
動的計画法したいけど、
同じ問題を2回以上提出する場合どうすればいいのかわからなくて諦めた
F
全探索したけど遅すぎて
全然改善できなかった
G
Fに沼ってノータッチ
感想
安心と信頼の3完
いつも通りすぎてなにも感想が出ない