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をPythonで取り組んだ振り返り(ABC402 A,B)

Posted at

どうもこんにちは!

今週もAtCoderのコンテストには参加しましたので記録します。
今回はBまで完答して終了しました。

問題

問題は以下のリンクから。取り組んだA,Bを振り返ります。

A - CBC -

指定された文字列から、大文字だけを抜き取って並べた文字列を出力する問題。1文字ずつ大文字かどうかを判定するisupper()関数で判定し、大文字だけを出力するとしました。最初の入力の受け取りを配列にしましたが、文字列として受け取っていても問題なかったと思います。

s = list(input())
ans = []

for i in s:
    if i.isupper() == True:
        ans.append(i)
print("".join(ans))

B - Restaurant Queue -

入力として与えられたクエリを処理した結果を出力する問題。クエリは2種類で、入力とした与えられた番号Xを待ち行列に追加することと、待ち行列の先頭の番号を出力して削除するというもの。
1行1クエリで与えられるので、1行読んで先頭の番号が1ならもう1つの入力の番号を待ち行列の追加、2なら待ち行列の先頭を出力するとしました。

n = int(input())
queue = []
for _ in range(n):
    tmp = input().split()
    if len(tmp) == 2:
        queue.append(tmp[1])
    else:
        print(queue.pop(0))

おわりに

明日(4/20)は情報技術者試験の試験日ですね。受験する方はがんばりましょう!

ではでは。

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?