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

ABC381Cを解いた【11/22】

Last updated at Posted at 2025-07-17

筆者はレート800前後の茶~緑コーダ

ABC381の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()
    S = rS()
    ans = 0
    sli = [i for i in range(N) if S[i] == '/']
    for i in sli:
        d = 0
        j=k=i
        while True:
            j -=1
            k +=1
            if not (0 <= j < N) or not(0 <= k < N):
                break
            if S[j] != '1' or S[k] != '2':
                break
            d += 1
        ans = max(ans, 2*d+1)
    print(ans)

if __name__ == "__main__":
    main()

感想

Atcoder Problemsみてたらこの回この問題だけWA出して終わってたので解いた

こういう取りこぼしを埋める作業が役に立つと信じたい。

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