結果
問題 | No.429 CupShuffle |
ユーザー | papinianus |
提出日時 | 2016-10-03 09:19:09 |
言語 | PHP (8.3.4) |
結果 |
AC
|
実行時間 | 121 ms / 2,000 ms |
コード長 | 892 bytes |
コンパイル時間 | 1,561 ms |
コンパイル使用メモリ | 32,272 KB |
実行使用メモリ | 74,168 KB |
最終ジャッジ日時 | 2024-05-01 11:13:49 |
合計ジャッジ時間 | 3,362 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
32,340 KB |
testcase_01 | AC | 34 ms
32,400 KB |
testcase_02 | AC | 33 ms
32,400 KB |
testcase_03 | AC | 32 ms
32,276 KB |
testcase_04 | AC | 32 ms
32,404 KB |
testcase_05 | AC | 31 ms
32,272 KB |
testcase_06 | AC | 32 ms
32,268 KB |
testcase_07 | AC | 32 ms
32,528 KB |
testcase_08 | AC | 31 ms
32,528 KB |
testcase_09 | AC | 32 ms
32,400 KB |
testcase_10 | AC | 40 ms
36,664 KB |
testcase_11 | AC | 115 ms
74,028 KB |
testcase_12 | AC | 96 ms
73,948 KB |
testcase_13 | AC | 121 ms
74,028 KB |
testcase_14 | AC | 107 ms
74,168 KB |
testcase_15 | AC | 34 ms
32,524 KB |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php list($n, $k, $x) = explode(" ",trim(fgets(STDIN))); $start = range(1, $n); $manipulate = []; for($i = $k;$i;$i--) { $manipulate[] = explode(" ",trim(fgets(STDIN))); } $goal = explode(" ",trim(fgets(STDIN))); $start = exchange($start, array_slice($manipulate,0,$x - 1)); $goal = exchange($goal, array_reverse(array_slice($manipulate,$x))); $diff = diff($start, $goal); sort($diff); echo (implode(" ",$diff)).PHP_EOL; function exchange($base, $acts) { foreach($acts as $act) { $a = $act[0]-1; //num to index $b = $act[1]-1; //num to index $tmp = $base[$b]; $base[$b] = $base[$a]; $base[$a] = $tmp; } return $base; } function diff($a, $b) { $res=[]; $len = count($a); for($i=0;$i < $len;$i++) { if($a[$i] != $b[$i]) { $res[] = $i+1; //index to num } } return $res; }