結果

問題 No.588 空白と回文
ユーザー motimoti
提出日時 2018-05-26 00:15:57
言語 Perl
(5.38.2)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 6,344 KB
実行使用メモリ 6,352 KB
最終ジャッジ日時 2023-09-11 03:33:53
合計ジャッジ時間 2,743 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
6,152 KB
testcase_01 AC 13 ms
6,264 KB
testcase_02 AC 13 ms
6,352 KB
testcase_03 AC 177 ms
6,136 KB
testcase_04 AC 13 ms
6,236 KB
testcase_05 AC 13 ms
6,216 KB
testcase_06 AC 14 ms
6,296 KB
testcase_07 AC 14 ms
6,232 KB
testcase_08 AC 14 ms
6,260 KB
testcase_09 AC 14 ms
6,292 KB
testcase_10 AC 15 ms
6,116 KB
testcase_11 AC 178 ms
6,096 KB
testcase_12 AC 166 ms
6,212 KB
testcase_13 AC 13 ms
6,204 KB
testcase_14 AC 13 ms
6,132 KB
testcase_15 AC 13 ms
6,068 KB
testcase_16 AC 14 ms
6,064 KB
testcase_17 AC 115 ms
6,072 KB
testcase_18 AC 14 ms
6,184 KB
testcase_19 AC 14 ms
6,212 KB
testcase_20 AC 170 ms
6,132 KB
testcase_21 AC 143 ms
6,192 KB
testcase_22 AC 166 ms
6,104 KB
testcase_23 AC 105 ms
6,092 KB
testcase_24 AC 13 ms
6,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

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++) {
  for (my $plus = 0; $plus < 2; $plus++) {
    my $count = 1 - $plus;
    for (my $i = 1; ; $i++) {
      my $left = $cent - $i + $plus;
      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;
0