結果

問題 No.1594 Three Classes
ユーザー harurunharurun
提出日時 2021-07-09 21:35:39
言語 PyPy3
(7.9.16)
結果
AC  
実行時間 586 ms / 2,000 ms
コード長 1,798 bytes
コンパイル時間 647 ms
実行使用メモリ 81,520 KB
最終ジャッジ日時 2022-12-17 01:40:06
合計ジャッジ時間 8,456 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 586 ms
81,424 KB
testcase_01 AC 82 ms
75,836 KB
testcase_02 AC 82 ms
75,420 KB
testcase_03 AC 125 ms
81,308 KB
testcase_04 AC 577 ms
81,484 KB
testcase_05 AC 577 ms
81,504 KB
testcase_06 AC 95 ms
81,012 KB
testcase_07 AC 108 ms
81,332 KB
testcase_08 AC 584 ms
81,116 KB
testcase_09 AC 583 ms
81,476 KB
testcase_10 AC 576 ms
81,036 KB
testcase_11 AC 575 ms
81,520 KB
testcase_12 AC 580 ms
81,028 KB
testcase_13 AC 81 ms
75,500 KB
testcase_14 AC 186 ms
81,328 KB
testcase_15 AC 279 ms
81,456 KB
testcase_16 AC 153 ms
81,324 KB
testcase_17 AC 317 ms
81,384 KB
testcase_18 AC 83 ms
75,744 KB
testcase_19 AC 101 ms
80,876 KB
testcase_20 AC 107 ms
81,052 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