ABC137(A~C)
A - +-x
https://atcoder.jp/contests/abc137/tasks/abc137_a
かかった時間 1分30秒
A,B=map(int,input().split()) p=A+B h=A-B k=A*B print(max(p,h,k))
B - One Clue
https://atcoder.jp/contests/abc137/tasks/abc137_b
かかった時間 4分
K,X=map(int,input().split()) List=[i for i in range(X-K+1,X+K)] print(" ".join(str(i) for i in List))
C - Green Bin
https://atcoder.jp/contests/abc137/tasks/abc137_c
かかった時間 20分
import collections from scipy.special import comb N=int(input()) List=[] for i in range(N): line=list(str(input())) line.sort() List.append("".join(line)) ans=0 for i,j in collections.Counter(List).items(): num=comb(j, 2, exact=True) ans+=num print(ans)
文字列がアナグラムの場合はソートしても同じ文字列になるので、最初のfor文ではそれを行っている。
次のfor文では、collections.Counterでリストの要素の出現回数を求めて、num=comb(j, 2, exact=True)で組み合わせの数を求める。
以下参考記事
collections.Counterの使い方
https://note.nkmk.me/python-collections-counter/
pythonの組み合わせ
https://qiita.com/Ma_AtoP/items/b9070518ff6e207e64a8