👌

AtCoder Beginner Contest 225

2022/04/07に公開

A - Distinct Strings

def main():
  c = len(set(list(input())))
  if c==1:
    print(1)
  elif c==2:
    print(3)
  else:
    print(6)
    
if __name__ == '__main__':
  main()

B - Star or Not

def main():
  n = int(input())
  dic = defaultdict(int)
  for _ in range(n-1):
    a,b = map(int, input().split())
    dic[a-1] += 1
    dic[b-1] += 1
  x,y = 0, 0
  for k,v in dic.items():
    if v==1:
      x += 1
    else:
      y += 1
  print("Yes" if x==n-1 and y==1 else "No")
  
if __name__ == '__main__':
  main()

C - Calendar Validator

import numpy as np

def main():
  n,m = map(int, input().split())
  b = [list(map(int, input().split())) for _ in range(n)]
  b = np.array(b)
  flg = True
  for i in range(m):
    if b[0][i]%7==0 and i!=m-1:
      flg = False
  for i in range(n):
    if m!=1 and set(np.diff(b[i]))!={1}:
      flg = False
  bt = b.T
  for i in range(m):
    if n!=1 and set(np.diff(bt[i]))!={7}:
      flg = False
  print('Yes' if flg else 'No')

if __name__ == '__main__':
  main()

Discussion