結果

問題 No.345 最小チワワ問題
ユーザー togaerrortogaerror
提出日時 2016-04-05 17:00:51
言語 Raku
(rakudo v2024.02)
結果
AC  
実行時間 605 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 141,120 KB
実行使用メモリ 146,072 KB
最終ジャッジ日時 2023-10-26 03:50:19
合計ジャッジ時間 20,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 533 ms
143,268 KB
testcase_01 AC 542 ms
143,456 KB
testcase_02 AC 552 ms
143,456 KB
testcase_03 AC 557 ms
143,448 KB
testcase_04 AC 559 ms
143,440 KB
testcase_05 AC 577 ms
143,420 KB
testcase_06 AC 566 ms
143,084 KB
testcase_07 AC 561 ms
143,452 KB
testcase_08 AC 548 ms
143,260 KB
testcase_09 AC 556 ms
143,316 KB
testcase_10 AC 548 ms
143,456 KB
testcase_11 AC 540 ms
143,260 KB
testcase_12 AC 605 ms
146,072 KB
testcase_13 AC 555 ms
143,364 KB
testcase_14 AC 586 ms
145,892 KB
testcase_15 AC 552 ms
143,312 KB
testcase_16 AC 570 ms
143,604 KB
testcase_17 AC 541 ms
143,456 KB
testcase_18 AC 532 ms
143,668 KB
testcase_19 AC 542 ms
143,028 KB
testcase_20 AC 547 ms
143,408 KB
testcase_21 AC 558 ms
143,404 KB
testcase_22 AC 536 ms
143,604 KB
testcase_23 AC 538 ms
143,280 KB
testcase_24 AC 553 ms
143,512 KB
testcase_25 AC 545 ms
143,516 KB
testcase_26 AC 544 ms
143,464 KB
testcase_27 AC 557 ms
143,316 KB
testcase_28 AC 549 ms
143,524 KB
testcase_29 AC 535 ms
143,456 KB
testcase_30 AC 535 ms
143,036 KB
testcase_31 AC 565 ms
143,452 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

use v6;

my @str = get().chomp.split('');

my $w = 0;
my $long = 0;
loop (my $i = 1; $i < @str.elems - 1; $i++) {
	if @str[$i] eq 'c' {
		loop (my $j = $i + 1; $j < @str.elems - 1; $j++) {
			if @str[$j] eq 'w' {
				if $w == 0 {
					$w++;
				} elsif $w == 1 {
					if $long == 0 {
						$long = $j - $i + 1;
					} elsif $j - $i + 1 < $long {
						$long = $j - $i + 1;
					}
					last;
				}
			}
		}
		$w = 0;
	}
}

if $long == 0 {
	say -1;
} else {
	say $long;
}
exit;
0