結果
問題 | No.643 Two Operations No.2 |
ユーザー | moti |
提出日時 | 2018-05-23 02:02:29 |
言語 | Perl (5.38.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 467 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 6,340 KB |
実行使用メモリ | 6,420 KB |
最終ジャッジ日時 | 2023-09-11 01:31:52 |
合計ジャッジ時間 | 1,291 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
6,208 KB |
testcase_01 | AC | 13 ms
6,180 KB |
testcase_02 | AC | 13 ms
6,124 KB |
testcase_03 | AC | 13 ms
6,388 KB |
testcase_04 | AC | 13 ms
6,208 KB |
testcase_05 | AC | 13 ms
6,104 KB |
testcase_06 | WA | - |
testcase_07 | AC | 13 ms
6,316 KB |
testcase_08 | WA | - |
testcase_09 | AC | 14 ms
6,212 KB |
testcase_10 | AC | 13 ms
6,208 KB |
testcase_11 | AC | 14 ms
6,288 KB |
testcase_12 | AC | 14 ms
6,372 KB |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my ($x, $y) = split / /, <>; chomp $y; if ($x == $y) { print 0; exit; } my @q; push @q, [$y, $x, 1]; push @q, [$x + $y, $x - $y, 1]; my %vis; while (scalar @q) { my $tup = shift @q; my ($x, $y, $c) = @{$tup}; if ($x == $y) { print $c; exit; } if (!exists $vis{$tup}) { $vis{$tup} = 1; push @q, [$y, $x, $c + 1]; push @q, [$x + $y, $x - $y, $c + 1]; } } print -1