結果

問題 No.2619 Sorted Nim
ユーザー とりゐとりゐ
提出日時 2024-01-26 22:35:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 106,816 KB
最終ジャッジ日時 2024-01-26 22:35:59
合計ジャッジ時間 8,296 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
54,100 KB
testcase_01 AC 41 ms
54,100 KB
testcase_02 AC 85 ms
100,604 KB
testcase_03 AC 100 ms
99,632 KB
testcase_04 AC 82 ms
100,932 KB
testcase_05 AC 84 ms
100,804 KB
testcase_06 AC 103 ms
101,916 KB
testcase_07 AC 81 ms
99,312 KB
testcase_08 AC 99 ms
101,556 KB
testcase_09 AC 42 ms
54,100 KB
testcase_10 AC 97 ms
99,656 KB
testcase_11 AC 86 ms
103,644 KB
testcase_12 AC 97 ms
99,408 KB
testcase_13 AC 41 ms
54,100 KB
testcase_14 AC 127 ms
99,656 KB
testcase_15 AC 88 ms
103,656 KB
testcase_16 AC 104 ms
101,580 KB
testcase_17 AC 103 ms
100,328 KB
testcase_18 AC 98 ms
99,880 KB
testcase_19 AC 81 ms
99,124 KB
testcase_20 AC 85 ms
100,440 KB
testcase_21 AC 104 ms
102,000 KB
testcase_22 AC 84 ms
101,804 KB
testcase_23 AC 99 ms
99,420 KB
testcase_24 AC 101 ms
101,268 KB
testcase_25 AC 130 ms
101,540 KB
testcase_26 AC 92 ms
106,756 KB
testcase_27 AC 82 ms
100,464 KB
testcase_28 AC 101 ms
100,424 KB
testcase_29 AC 103 ms
101,676 KB
testcase_30 AC 92 ms
106,816 KB
testcase_31 AC 41 ms
54,100 KB
testcase_32 AC 83 ms
99,844 KB
testcase_33 AC 87 ms
103,832 KB
testcase_34 AC 82 ms
99,652 KB
testcase_35 AC 90 ms
105,396 KB
testcase_36 AC 98 ms
99,644 KB
testcase_37 AC 43 ms
54,100 KB
testcase_38 AC 82 ms
101,076 KB
testcase_39 AC 98 ms
99,868 KB
testcase_40 AC 83 ms
100,640 KB
testcase_41 AC 84 ms
100,652 KB
testcase_42 AC 82 ms
100,288 KB
testcase_43 AC 99 ms
99,856 KB
testcase_44 AC 97 ms
99,372 KB
testcase_45 AC 97 ms
99,856 KB
testcase_46 AC 92 ms
105,232 KB
testcase_47 AC 85 ms
100,616 KB
testcase_48 AC 59 ms
54,100 KB
testcase_49 AC 88 ms
103,656 KB
testcase_50 AC 83 ms
100,616 KB
testcase_51 AC 89 ms
105,100 KB
testcase_52 AC 41 ms
54,100 KB
testcase_53 AC 102 ms
102,004 KB
testcase_54 AC 82 ms
100,452 KB
testcase_55 AC 102 ms
100,304 KB
testcase_56 AC 85 ms
103,820 KB
testcase_57 AC 101 ms
101,672 KB
testcase_58 AC 100 ms
101,232 KB
testcase_59 AC 86 ms
103,820 KB
testcase_60 AC 83 ms
99,808 KB
testcase_61 AC 85 ms
100,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

s={}

def naive(a):
  if max(a)==0:
    return 0
  if tuple(a) in s:
    return s[tuple(a)]
  g=set()
  res=[]
  for i in range(len(a)):
    for j in range(1,a[i]+1):
      b=a.copy()
      b[i]-=j
      if b==sorted(b):
        g.add(naive(b))
  
  t=0
  while t in g:
    t+=1
  s[tuple(a)]=t
  return t

def solve(a):
  b=a.copy()
  if len(a)%2==1:
    b=[0]+a
  xor=0
  for i in range(0,len(b),2):
    xor^=b[i+1]-b[i]
  return xor

import random
for _ in range(0):
  n=random.randint(3,5)
  a=[random.randint(1,5) for i in range(n)]
  a.sort()
  if naive(a)!=solve(a):
    print(a,naive(a),solve(a))

n=int(input())
a=list(map(int,input().split()))
if solve(a)!=0:
  print('First')
else:
  print('Second')
0