0
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?

前回の振り返り

今日はABC405開催日だったので参加結果を振り返る

今週はA,B,C,Dの4完(0ペナ)

A

脳筋if文

ソースコード

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():
    R, X = rLI()
    
    ans = False
    if X==1 and 1600 <= R <= 2999:
        ans = True
    if X==2 and 1200 <= R <= 2399:
        ans = True
    print('Yes' if ans else 'No')
    
if __name__ == '__main__':
    main()

B

脳筋while文

ソースコード

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 chk(A,M):
    for i in range(M):
        if A.count(i+1) == 0:
            return False
    return True

def main():
    N, M = rLI()
    A = rLI()
    c = 0
    while chk(A,M):
        A.pop()
        c+=1
    print(c)
    
if __name__ == '__main__':
    main()

C

分配法則を考えてかける数を累積和でまとめる。
そしてあとは順番に処理。

ソースコード

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()
    S = list(accumulate(A))
    err(S)
    ans = 0
    for i,a in enumerate(A):
        ans += a*(S[-1]-S[i])
    
    print(ans)
    
if __name__ == '__main__':
    main()

D

非常口からBFSして、移動方向とは逆の矢印を置く。
最短経路である条件なので、
一応より短いルートがないかチェックしておく。

ソースコード

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():
    H, W = rLI()
    S = [rS() for _ in range(H)]
    grid = [0]*H
    q = deque()
    dist = [[float('inf')] * W for _ in range(H)]
    for i,s in enumerate(S):
        grid[i] = list(s)
        for j,t in enumerate(s):
            if t == "E":
                q.append([i,j])
                dist[i][j] = 0
    dy = [-1, 0, 1, 0]
    dx = [0, 1, 0, -1]
    dc = ["v","<","^",">"]
    
    def out_of_bounds(y, x):
        return y < 0 or y >= H or x < 0 or x >= W
    
    
    while q:
        y, x = q.popleft()
        for di in range(4):
            ny, nx = y + dy[di], x + dx[di]
            if not out_of_bounds(ny, nx) and grid[ny][nx] not in "#E" and dist[ny][nx]>(dist[y][x]+1):
                # err(y,x,ny,nx,dc[di])
                dist[ny][nx] = dist[y][x] + 1
                grid[ny][nx] = dc[di]
                q.append((ny, nx))
    for s in grid:
        print("".join(s))
    # if IS_LOCAL:
    #     for d in dist:
    #         err(*d)

    
if __name__ == '__main__':
    main()

E

りんご、オレンジの並べ替えだけと
バナナ、ぶどうだけの並べ替えは考えたけど
間の並べ替えがピンとくるのがなかった

F

円上に等間隔で配置された点がでてくる系の問題最近多くない?

G

面白そうだけどG問題に飛び込む自力勇気その他が足りないので撤退

感想

D問題まではすんなりいけたが、
E問題以降がよくわからんので早々に諦めて別のことしてた

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?