1
0

STEP: 1 アイドルグループ

Posted at

今週前半はAWSの試験があり、直前だったので一旦お休みしてました。

N,K = map(int,input().split())
A = {input() for i in range(N)}
for _ in range(K):
    command = input().split()
    if command[0] == 'handshake':
        for name in sorted(A):
            print(name)
    elif command[0] == 'leave':
        A.remove(command[1])
    else:
        A.add(command[1])

久しぶりだったのでちょっとど忘れしたりして長引いてしまいました。

キー無しの辞書は{}でできて、
削除や追加はremove,addでできる。
順序はもちろんsortedで。

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