結果
| 問題 |
No.588 空白と回文
|
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2018-05-26 00:14:03 |
| 言語 | Perl (5.40.0) |
| 結果 |
AC
|
| 実行時間 | 139 ms / 2,000 ms |
| コード長 | 714 bytes |
| コンパイル時間 | 418 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2024-06-28 18:07:09 |
| 合計ジャッジ時間 | 2,395 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
use strict;
use warnings;
use Data::Dumper;
my $line = <>; chomp $line;
unless (length $line) {
print 0;
exit;
}
my @arr = split //,$line;
my $max = 1;
for (my $cent = 0; $cent < scalar @arr; $cent++) {
my $count = 1;
for (my $i = 1; ; $i++) {
my $left = $cent - $i;
my $right = $cent + $i;
last if $left < 0;
last if $right >= scalar @arr;
$count += 2 if $arr[$left] eq $arr[$right];
}
$max = $count if $max < $count;
$count = 0;
for (my $i = 1; ; $i++) {
my $left = $cent - $i + 1;
my $right = $cent + $i;
last if $left < 0;
last if $right >= scalar @arr;
$count += 2 if $arr[$left] eq $arr[$right];
}
$max = $count if $max < $count;
}
print $max;
moti