ABC124ただの感想
どうもーーー
さて、懲りずにABC参加。
結果はABC3完(57m)
普通に爆死。
つらい。
でもABCに限って言えば、今回ほど出来が悪い回は無いという感触なので、もう大丈夫だと思う。
今回の最大の敗因。
それはB問題。
条件を取り違えていた。
これ、H1 <= Hi、かつH2 <= Hi、かつ、Hi-i <= Hiであれば良いという条件と間違えた。
本来は前にあるどの山よりも大きいという条件なのに。
しかも不運なことに、これに気づかなかったばかりか、質問を見てみたら改行の問題でWAになってましたみたいな。
ああー、これ俺のこと??
と思って放置してCを解き始める。
C解けたからB見たけどまだ直ってないなー。
まあD考えよう。
あー、rejudgeされてる??
B見たけど直ってない???
これは俺のミス
ってなってあわてて上の条件を何回も何回も見直しました。
さすがに自分を殺したくなった。
A:
普通にアホみたいに実直に問題文を再現した。
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10**7) inf = 10 ** 20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def _I(): return int(sys.stdin.readline()) def _F(): return float(sys.stdin.readline()) def pf(s): return print(s, flush=True) A, B = LI() ans = 0 for i in range(2): if A >= B: ans += A A -= 1 else: ans += B B -= 1 print(ans)
B:
死んだ。
ある山の前にある全ての山が低いか同じ高さであることを証明。
てか2個目のifいらんやん。
焦りが見える。
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10**7) inf = 10 ** 20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def _I(): return int(sys.stdin.readline()) def _F(): return float(sys.stdin.readline()) def pf(s): return print(s, flush=True) N = _I() H = LI() ans = 1 for i in range(1, N): if all(H[j] <= H[i] for j in range(0,i)): if H[i-1] <= H[i]: ans += 1 print(ans)
C:
ここ最近の傾向として、AtCoderのそもそもの人気もそうだけど、受験が終わって強い若者が続々参入してきて、明らかに
パフォーマンスが出にくい。
強いひとたち早くABC卒業してほしいいい。
あと、最近のCが簡単すぎるっていうのもある??
Dとの差が大きい感じ。
問題のほうは、交互に塗る0101010か、101010101
しかないので、最初を0にする場合と、最初を1にする場合でどちらが手数が少ないかを比べるだけ。
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10**7) inf = 10 ** 20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def _I(): return int(sys.stdin.readline()) def _F(): return float(sys.stdin.readline()) def pf(s): return print(s, flush=True) S = input() # 2通り試せばいい # 最初を0にするか1にするか current = '0' ans1 = 0 for s in S: if s == current: if current == '0': current = '1' else: current = '0' else: # 塗り直し if current == '0': current = '1' else: current = '0' ans1 += 1 current = '1' ans2 = 0 for s in S: if s == current: if current == '0': current = '1' else: current = '0' else: # 塗り直し if current == '0': current = '1' else: current = '0' ans2 += 1 print(min(ans1, ans2))
D:
Dの中では簡単な方だったのではないか。
実際通した人も多かった模様。
自分も考察は合ってたが、焦ってたのもあって実装ミス。
0の区間をリストアップ。
011001100
なら
0~1, 3~5, 7~9
みたいな。
0~1と7~9だけ反転しても意味がないので、隣り合った区間を同時に反転させる。
これは左から右に区間をスライドしていけばよい。
0~1、3~5反転
3~5、7~9反転
というように。
その際、始点と終点だけ考えれば良いので実際に反転させる必要はない。
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10**7) inf = 10 ** 20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def _I(): return int(sys.stdin.readline()) def _F(): return float(sys.stdin.readline()) def pf(s): return print(s, flush=True) N, K = LI() S = input() positions = [] idx = 0 keep = None while idx < N: if S[idx] == '0': if keep == None: keep = idx else: # 1の場合は無視 if keep != None: positions.append([keep, idx]) keep = None else: # keepしない場合 keep = None idx += 1 else: if keep != None: positions.append([keep, keep+1]) # print(positions) if len(positions) == 0: print(N) exit() elif len(positions) <= K: print(N) exit() ans = 0 for idx in range(len(positions)): if idx + K - 1 > len(positions) - 1: break if idx == 0: left = 0 else: left = positions[idx-1][1] if idx + K - 1 == len(positions)-1: end = N else: end = positions[idx+K-1+1][0] # print(end, left) ans = max(ans, end - left) print(ans)
最近の精進は、彼女がメキシコから来たのでずっと家で書くわけにもいかず、基本は移動時間にスマホで
投稿するというスタイルが多い。
こんな感じ。
誰かモバイルの良いpython editorあれば教えてください。
python3 ideは日本語入ってると落ちるのでやめました。