結果

問題 No.1594 Three Classes
ユーザー harurunharurun
提出日時 2021-07-09 21:35:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 584 ms / 2,000 ms
コード長 1,798 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 77,336 KB
最終ジャッジ日時 2023-08-10 06:43:47
合計ジャッジ時間 8,357 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 583 ms
77,264 KB
testcase_01 AC 70 ms
71,084 KB
testcase_02 AC 71 ms
71,452 KB
testcase_03 AC 112 ms
77,096 KB
testcase_04 AC 581 ms
77,184 KB
testcase_05 AC 582 ms
77,112 KB
testcase_06 AC 80 ms
76,596 KB
testcase_07 AC 95 ms
76,952 KB
testcase_08 AC 584 ms
77,152 KB
testcase_09 AC 577 ms
77,336 KB
testcase_10 AC 579 ms
77,136 KB
testcase_11 AC 584 ms
77,292 KB
testcase_12 AC 581 ms
76,996 KB
testcase_13 AC 70 ms
71,444 KB
testcase_14 AC 176 ms
77,296 KB
testcase_15 AC 270 ms
76,996 KB
testcase_16 AC 140 ms
77,040 KB
testcase_17 AC 307 ms
77,208 KB
testcase_18 AC 70 ms
71,224 KB
testcase_19 AC 88 ms
76,732 KB
testcase_20 AC 94 ms
77,228 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