前回の振り返り
今日はABC開催日だったので参加結果を振り返る
今週はのA,B,C完(1ペナ)
- そして終了20分弱後にDをAC…
A
4個を2回としてカウントせずに1ペナ
ソースコード
main.py
from collections import Counter
a=list(map(int,input().split()))
c=Counter(Counter(a).values())
print(c.get(2,0)+c.get(3,0)+c.get(4,0)*2)
B
剰余の管理もグラフほどではないが難しい…
ソースコード
main.py
import sys
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())
def err(*args): print(*args, file=sys.stderr)
def main():
N = rI()
A = [rLI() for _ in range(N)]
Q = rI()
for _ in range(Q):
t, d = rLI()
q, r = A[t-1]
w = d//q
ans = w*q+r
if ans < d:
ans += q
print(ans)
if __name__ == '__main__':
main()
C
defaultdict君大活躍
ソースコード
main.py
import sys
from collections import defaultdict
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())
def err(*args): print(*args, file=sys.stderr)
d = defaultdict(lambda: -1)
def main():
N = rI()
A = rLI()
B = [-1] * N
for i,a in enumerate(A, start=1):
B[i-1]=d[a]
d[a]=i
print(*B)
if __name__ == '__main__':
main()
D
苦手ジャンルのグリッド問題
DPしたけど時間内にTLE取れず…
回数しかテーブルの添字に入れていなかったのでマス目を追加にしたらACした
ソースコード
main.py
import sys
from collections import deque
from itertools import product
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())
def err(*args): print(*args, file=sys.stderr)
def main():
H, W, K = rLI()
Field = [rS() for _ in range(H)]
dp = [[[[] for _ in range(K+1)] for _ in range(W)] for _ in range(H)]
for h,w in product(range(H),range(W)):
if Field[h][w] == "#": continue
dp[h][w][0].append([(h,w)])
dh = [1, -1, 0, 0]
dw = [0, 0, -1, 1]
ans = 0
for k in range(1,K+1):
for h,w in product(range(H),range(W)):
if Field[h][w] == "#": continue
for i in range(4):
nh = h + dh[i]
nw = w + dw[i]
if 0 <= nh < H and 0 <= nw < W and Field[nh][nw] == ".":
for path in dp[nh][nw][k-1]:
if (h,w) in path:continue
if K < 3 :err(path)
if k < K:
dp[h][w][k].append(path+[(h,w)])
else:
ans += 1
# if len(dp[k]) < 10:err(dp[k])
# print(len(dp[K]))
print(ans)
if __name__ == "__main__":
main()
E
Dが苦手なので15分くらい考えたけど、
まあE問題だし厳しいやろってことでキャンセル
F
グラフの問題は以下略
G
回答者数少なくない?
そして公式解説の
ロビンソン・シェンステッド対応の練習問題です
ていう、この既視感のある書き出しは草
まとめ
Dが苦手ジャンル過ぎて一旦E問題に逃げたけど
多分その時間使えば間に合った説