結果

問題 No.429 CupShuffle
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2016-10-02 23:42:55
言語 Ruby
(3.2.2)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 1,027 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 11,488 KB
実行使用メモリ 28,524 KB
最終ジャッジ日時 2023-08-13 18:16:38
合計ジャッジ時間 2,998 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
15,048 KB
testcase_01 AC 65 ms
15,160 KB
testcase_02 AC 65 ms
15,292 KB
testcase_03 AC 66 ms
15,040 KB
testcase_04 AC 69 ms
15,216 KB
testcase_05 AC 66 ms
15,240 KB
testcase_06 AC 71 ms
15,156 KB
testcase_07 AC 67 ms
15,092 KB
testcase_08 AC 66 ms
15,140 KB
testcase_09 AC 68 ms
15,128 KB
testcase_10 AC 87 ms
16,416 KB
testcase_11 AC 283 ms
28,476 KB
testcase_12 AC 287 ms
28,280 KB
testcase_13 AC 310 ms
28,524 KB
testcase_14 AC 298 ms
28,372 KB
testcase_15 AC 68 ms
15,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N,K,X=gets.split.map(&:to_i)
perms=[]
K.times{
    a,b=gets.split.map(&:to_i)
    a-=1
    b-=1
    perms.push([a,b])
}

poses1=(0...N).to_a
poses2=gets.split.map(&:to_i).map{|i| i-1}

(0...X-1).each{|i|
    #puts "test1: pre : poses1[perms[i][0]],poses1[perms[i][1]]=#{poses1[perms[i][0]]},#{poses1[perms[i][1]]},#{poses1.to_a}"
    poses1[perms[i][0]],poses1[perms[i][1]] = poses1[perms[i][1]],poses1[perms[i][0]]
    #puts "test1: post: poses1[perms[i][0]],poses1[perms[i][1]]=#{poses1[perms[i][0]]},#{poses1[perms[i][1]]},#{poses1.to_a}"
}

(K-1).downto(X).each{|i|
    #puts "test2: pre : poses2[perms[i][0]],poses2[perms[i][1]]=#{poses2[perms[i][0]]},#{poses2[perms[i][1]]},#{poses2.to_a}"
    poses2[perms[i][0]],poses2[perms[i][1]] = poses2[perms[i][1]],poses2[perms[i][0]]
    #puts "test2: post: poses2[perms[i][0]],poses2[perms[i][1]]=#{poses2[perms[i][0]]},#{poses2[perms[i][1]]},#{poses2.to_a}"
}

result=[]
(0...N).each{|j|
    if(poses1[j] != poses2[j])
        result.push(j+1)
    end
}

puts result.join(' ')
0