結果

問題 No.241 出席番号(1)
ユーザー kazasikikazasiki
提出日時 2015-07-28 10:18:35
言語 Ruby
(3.2.2)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 11,316 KB
実行使用メモリ 15,372 KB
最終ジャッジ日時 2023-08-20 17:50:39
合計ジャッジ時間 4,513 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,272 KB
testcase_01 AC 81 ms
15,116 KB
testcase_02 AC 80 ms
15,156 KB
testcase_03 AC 81 ms
15,288 KB
testcase_04 AC 83 ms
15,180 KB
testcase_05 AC 81 ms
15,076 KB
testcase_06 AC 81 ms
15,112 KB
testcase_07 AC 80 ms
15,212 KB
testcase_08 AC 80 ms
15,244 KB
testcase_09 AC 81 ms
15,112 KB
testcase_10 AC 81 ms
15,088 KB
testcase_11 AC 82 ms
15,240 KB
testcase_12 AC 81 ms
15,324 KB
testcase_13 AC 81 ms
15,248 KB
testcase_14 AC 83 ms
15,112 KB
testcase_15 AC 81 ms
15,300 KB
testcase_16 AC 82 ms
15,360 KB
testcase_17 AC 81 ms
15,088 KB
testcase_18 AC 83 ms
15,176 KB
testcase_19 AC 81 ms
15,372 KB
testcase_20 AC 81 ms
15,300 KB
testcase_21 AC 81 ms
15,300 KB
testcase_22 AC 80 ms
15,144 KB
testcase_23 AC 80 ms
15,176 KB
testcase_24 AC 81 ms
15,072 KB
testcase_25 AC 83 ms
15,324 KB
testcase_26 AC 83 ms
15,320 KB
testcase_27 AC 81 ms
15,156 KB
testcase_28 AC 80 ms
15,156 KB
testcase_29 AC 81 ms
15,300 KB
testcase_30 AC 81 ms
15,272 KB
testcase_31 AC 81 ms
15,364 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:39: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

# input
N = gets.to_i
A = N.times.map{
      gets.to_i
    }
R = Random.new(2)

def dec_nums nums
  array = (0...nums.size).to_a
  nums.map{|i| array.delete_at(i)}
end

def generate_nums size
  (0...size).map{|i| rand(0...(size-i))}
end

def check_nums nums
  nums.each.with_index{|num, i|
    return i if nums[i] == A[i]
  }
  return nil
end

def change_nums nums, index
  indexs = (0...nums.size).to_a
  indexs.delete(index)
  i = indexs.sample
  tmp = nums[index]
  nums[index] = nums[i]
  nums[i] = tmp
end

def check_A
  A.each{|i| return false if i >= N}
  A.uniq.size == 1
end

if check_A
  p -1
else
  nums = dec_nums(generate_nums(N))
  while (ng = check_nums(nums)) != nil
    change_nums nums, ng
  end
  nums.each{|i| p i }
end
0