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?

ABC381

Posted at

2024/11/22にABC381が開催されました。いつものように挑んだのですが、まさかの0完!
今回のABCはwhileループを使用する問題で構成されていました。
敗因は私がwhileループを理解していなかったから。
復習と反省を兼ねてA,B,C問題の回答をpythonで書きました。

ABC381A
N = int(input())
s = list(input())
isYes = True
if N%2 == 0:
  isYes = False
else:
  for i in range(N//2):
    if s[i]=='1' and s[-(1+i)]=='2':
      continue
    isYes = False
  if s[N//2]!='/':
    isYes = False
if isYes:
  print('Yes')
else:
  print('No')
ABC381B
s = list(input())
isYes = True
if len(s)%2!=0:
  isYes = False
else:
  for i in range((len(s)//2)):
    if s[2*i] == s[2*i+1] and s.count(s[i]) == 2:
      continue
    isYes = False
if isYes:
  print('Yes')
else:
  print('No')
ABC381C
N=int(input())
s=input()
answer = 0
for i in range(N):
  if s[i] == '/':
    n = 1
    now1 = i
    now2 = i
    while True:
      now1 -= 1
      now2 += 1
      if now1 < 0 or now2 > N - 1:
        break
      if s[now1] != "1" or s[now2] != "2":
        break
    now1 += 1
    now2 -= 1
    answer = max(answer,now2 - now1 + 1)
print(answer)
0
0
3

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?