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?

【AtCoder】ABC409 振り返り📝

Last updated at Posted at 2025-06-13

Zennに置いていた記事をQiitaに転載しています。

ABC409 - A

問題はこちら
最近フロントエンドばっかり書いていたからPythonの書き方をすべて忘れ去っていて、inputをintにする方法すらわからなくて焦った…
まあ解けたは解けたからOKかな?

n = int(input())
a = input()
b = input()

for i in range(n):
    if(a[i]=="o" and  a[i]==b[i]):
        print("Yes")
        break
    if(i==n-1):
        print("No")

ABC409 - B

問題はこちら
見える範囲のテストケースは通ったのに提出した後のテストケースでWAしてワーーーー???ってなった。
結局 5 5 5 5 5 5 みたいな同じ数字の時がダメだったんだけど、これ見つけるのに15分くらいかかってしまったので、これくらいすぐわかりたかったな~の気持ち。

n = int(input())
a = list(map(int, input().split()))

for i in range (max(a)+1):  #0~max(a)
    count = 0
    for j in range (n): #a[0]~a[n-1]
        if(a[j] >= i):
            count += 1
    if(count < i):
        print(i-1)
        break
    elif(i==max(a)):
        print(i)

ABC409 - C

問題はこちら
これ!!!私の中では解けてるのに!!!TLEです!!!!!!
モウムリィ…

n,l = map(int, input().split())
d = list(map(int, input().split()))


tenP = [0]*n
for i in range(n-1):
    tenP[i+1] = (tenP[i]+d[i])%l

if(l%3 != 0):
    print(0)
else:
    tri = 0
    for i in range(n):
        if(tenP[i] < l/3):
            tri += tenP.count(tenP[i]+l/3)*tenP.count(tenP[i]+2*l/3)
            
    print(tri)

今回の感想

久々の参加にしてはがんばったかな?
同期とAtCoderの話題で盛り上がっていて、一緒に参加できる人がいるのって楽しいな~の気持ちです。
大学時代は友達いなさ過ぎて何するにも孤独だったので…

2025/06/11 追記

QiitaってAtCoderの記事あるんかな~って眺めてたらたまたま見つけてとてもわかりやすかったので、
AtCoder ABC409 振り返り(緑コーダーがPythonでABCD問題)

書き直してみた!

n,l = map(int, input().split())
d = list(map(int, input().split()))

# 円周が3の倍数でないときは正三角形が存在しない
if l % 3 != 0:
    print(0)
    exit()


points = [0]*(l+1) # 点Pに何個あるか
points[0] = 1
current = 0

# 各点がどの点に配属されるか
for num in d:
    current = (current+num) % l
    points[current] += 1

# 三角形の数を数える
count = 0
for i in range(l//3 + 1):
    point1 = points[i]
    point2 = points[i + l//3]
    point3 = points[i + 2*(l//3)]
    count += point1 * point2 * point3

print(count)

確かにDの各点の位置求めてcountするより、点Pに何個あるかを記録しておく方が計算量少ないよな~
グワァ 納得感と敗北感……

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?