結果

問題 No.1594 Three Classes
ユーザー harurunharurun
提出日時 2021-07-09 21:35:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 516 ms / 2,000 ms
コード長 1,798 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2024-04-28 00:02:03
合計ジャッジ時間 6,549 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 506 ms
75,916 KB
testcase_01 AC 37 ms
52,864 KB
testcase_02 AC 36 ms
52,224 KB
testcase_03 AC 85 ms
76,032 KB
testcase_04 AC 507 ms
75,700 KB
testcase_05 AC 504 ms
76,032 KB
testcase_06 AC 47 ms
62,464 KB
testcase_07 AC 66 ms
75,824 KB
testcase_08 AC 501 ms
76,160 KB
testcase_09 AC 508 ms
76,096 KB
testcase_10 AC 503 ms
75,844 KB
testcase_11 AC 514 ms
75,904 KB
testcase_12 AC 516 ms
75,832 KB
testcase_13 AC 36 ms
52,224 KB
testcase_14 AC 149 ms
76,032 KB
testcase_15 AC 233 ms
76,016 KB
testcase_16 AC 115 ms
75,956 KB
testcase_17 AC 263 ms
76,032 KB
testcase_18 AC 36 ms
52,608 KB
testcase_19 AC 58 ms
67,712 KB
testcase_20 AC 71 ms
75,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class INPUT:
  def __init__(self):
    self._l=open(0).read().split()
    self._length=len(self._l)
    self._index=0
    return

  def stream(self,k=1,f=int,f2=False):
    assert(-1<k)
    if self._length==self._index or self._length-self._index<k:
      raise Exception("There is no input!")
    elif f!=str:
      if k==0:
        ret=list(map(f,self._l[self._index:]))
        self._index=self._length
        return ret
      if k==1 and not f2:
        ret=f(self._l[self._index])
        self._index+=1
        return ret
      if k==1 and f2:
        ret=[f(self._l[self._index])]
        self._index+=1
        return ret
      ret=[]
      for _ in [0]*k:
        ret.append(f(self._l[self._index]))
        self._index+=1
      return ret
    else:
      if k==0:
        ret=list(self._l[self._index:])
        self._index=self._length
        return ret
      if k==1 and not f2:
        ret=self._l[self._index]
        self._index+=1
        return ret
      if k==1 and f2:
        ret=[self._l[self._index]]
        self._index+=1
        return ret
      ret=[]
      for _ in [0]*k:
        ret.append(self._l[self._index])
        self._index+=1
      return ret
pin=INPUT().stream


#pin(number[default:1],f[default:int],f2[default:False])
#if number==0 -> return left all
#listを変数で受け取るとき、必ずlistをTrueにすること。

def change(n,k):
  ret=[]
  while n!=0:
    ret.append(str(n%k))
    n//=k
  return "".join(ret)

def main():
  N=pin(1)
  E=pin(0)
  for i in range(pow(3,N)):
    a=b=c=0
    u=change(i,3)
    s=N-len(u)
    t="0"*s+u
    for i in range(N):
      if t[i]=="0":
        a+=E[i]
      elif t[i]=="1":
        b+=E[i]
      else:
        c+=E[i]
    if a==b and b==c:
      print("Yes")
      return
  print("No")
  return

main()
0