結果

問題 No.1909 Detect from Substrings
ユーザー tails
提出日時 2022-04-22 21:22:46
言語 Perl
(5.40.0)
結果
AC  
実行時間 434 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 6,016 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-06-24 02:24:04
合計ジャッジ時間 10,856 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::n" used only once: possible typo at Main.pl line 18.
Main.pl syntax OK

ソースコード

diff #

sub check{
	for$s(@s){
		$k=0;
		while(substr($t,$k,1) eq substr($s,$k,1)){
			++$k;
		}
		while($k<$m && substr($t,$k+1,1) eq substr($s,$k,1)){
			++$k;
		}
		if($k!=$m){
			return 0;
		}
	}
	return 1;
}


($n,$m)=glob<>;
@s=<>;
while(substr($s[0],$i,1) eq substr($s[1],$i,1)){
	++$i;
}
$j=$m-1;
while(substr($s[0],$j,1) eq substr($s[1],$j,1)){
	--$j;
}
$r+=check($t=substr($s[0],0,$j+1).substr($s[1],$j));
$r+=check($t=substr($s[1],0,$j+1).substr($s[0],$j));
print $r;
0