前回の振り返り
今日はABC開催日だったので参加結果を振り返る
今週はA,B,C,Dの4完(2ペナ)
A
=
をNが奇数なら1つ、偶数なら2つおいて
それ以外は-
で埋める
ソースコード
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 = rI()
e = 1
if N % 2 == 0:
e += 1
m = (N-e)//2
print("-"*m+"="*e+"-"*m)
if __name__ == '__main__':
main()
B
カウンターで3枚以上かつ2枚以上あるか判定
ソースコード
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():
A = rLI()
c = Counter(A)
for i,j in combinations(c,2):
x,y=c[i],c[j]
if x < y: x,y=y,x
if x>=3 and y>=2:
print("Yes")
break
else:
print("No")
if __name__ == '__main__':
main()
C
Counterで1個しかない奴判定で
順番に値が大きい人の番号を探す
問題文読んでなくて1ペナ
ソースコード
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 = rI()
A = rLI()
c = Counter(A)
m = 0
ans = -1
for i,a in enumerate(A,start=1):
if c[a]==1 and m < a:
m = a
ans = i
print(ans)
if __name__ == '__main__':
main()
D
煙の代わりに焚き火と高橋君を動かす。
文字列の足し算に時間かかって1ペナ
ソースコード
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)
move = {"N":(1,0),"S":(-1,0),"E":(0,-1),"W":(0,1)}
d = defaultdict(lambda: 0)
def main():
N, R, C = rLI()
y,x=R,C
i=j=0
S = rS()
ans = []
d[(i,j)]=1
# ans+=d[(y,x)]
for s in S:
dr,dc=move[s]
y+=dr
x+=dc
i+=dr
j+=dc
d[(i,j)]=1
ans.append(d[(y,x)])
print(*ans,sep="")
if __name__ == '__main__':
main()
E
インタラクティブな問題はやったことないですね…
F
シンプルな問題だけど
適当にやってみてダメそうだったからパス
G
グラフ+ゲームというね
感想
久々の4完、今回はCounterとdefaultdict君活躍回(?)