結果

問題 No.1005 BOT対策
ユーザー hogehoge
提出日時 2021-01-02 21:11:05
言語 Perl
(5.40.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 7,072 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 11:11:33
合計ジャッジ時間 1,430 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
\1 better written as $1 at Main.pl line 9.
Main.pl syntax OK

ソースコード

diff #

use strict;

chomp(my $s = <>);
chomp(my $t = <>);

my $c = 0;
if ($t =~ /^(.)(\g1+)$/) {
    my $n = length($t);
    while ($s =~ s/\Q$t\E($1*)/\1/) {
        $c++;
        $c++ if length($1) // $n != 0;
    }
} else {
    while ($s =~ /(\Q$t\E)/g) {
        $c++;
    }
}
if ($c && (length($t) == 1 || $t =~ /^\.+$/)) {
    print("-1\n");
} else {
    print($c, "\n");
}
0