結果

問題 No.1885 Flat Permutation
ユーザー maimai
提出日時 2022-03-25 23:13:15
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 88,064 KB
最終ジャッジ日時 2024-04-22 08:07:26
合計ジャッジ時間 23,949 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,288 KB
testcase_01 AC 87 ms
12,032 KB
testcase_02 AC 88 ms
12,032 KB
testcase_03 WA -
testcase_04 AC 92 ms
12,288 KB
testcase_05 AC 89 ms
12,160 KB
testcase_06 AC 89 ms
12,160 KB
testcase_07 AC 88 ms
12,288 KB
testcase_08 AC 90 ms
12,160 KB
testcase_09 AC 91 ms
12,288 KB
testcase_10 AC 88 ms
12,288 KB
testcase_11 AC 91 ms
12,032 KB
testcase_12 AC 87 ms
12,032 KB
testcase_13 AC 87 ms
12,160 KB
testcase_14 AC 89 ms
12,032 KB
testcase_15 AC 90 ms
12,288 KB
testcase_16 AC 86 ms
12,160 KB
testcase_17 AC 89 ms
12,160 KB
testcase_18 AC 89 ms
12,032 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 86 ms
12,160 KB
testcase_24 AC 88 ms
12,160 KB
testcase_25 AC 86 ms
12,288 KB
testcase_26 AC 87 ms
12,032 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 87 ms
12,288 KB
testcase_33 AC 86 ms
12,288 KB
testcase_34 AC 87 ms
12,288 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 90 ms
12,160 KB
testcase_38 AC 87 ms
12,160 KB
testcase_39 AC 87 ms
12,032 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def lscan; gets.split.map(&:to_i); end


def fibo(n)
  return 1 if n <= 0
  a1 = 1
  a2 = 0
  a3 = 0
  n.times do
    b1 = a2 + a1
    b2 = a3 + 0
    b3 =  0 + a1
    a1,a2,a3=b1,b2,b3
    # p [a1,a2,a3]
  end
  a1
end

def solve(n,x,y)
  return 1 if n <= 2
  return solve(n,y,x) if x > y
  
  x -= 1 if x == 1
  y += 1 if y == n
  
  return 0 if y - x <= 1
  
  fibo(y-x-2)
end


n,x,y = lscan

# (1..n).each do |x|
#   (1..n).each do |y|

# a = (1..n).to_a.permutation(n).count {|li|
#   li[0] == x && li[-1] == y && li.each_cons(2).all?{|a, b| (a-b).abs <= 2}
# }

# a -= solve(n,x,y)

# printf "%3d", a
# end
# puts
# end

p solve(n,x,y)
0