結果

問題 No.273 回文分解
ユーザー eses
提出日時 2015-09-26 20:55:48
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 18,684 KB
実行使用メモリ 19,020 KB
最終ジャッジ日時 2023-08-25 00:20:57
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 16 ms
18,912 KB
testcase_04 AC 15 ms
18,884 KB
testcase_05 AC 16 ms
18,912 KB
testcase_06 AC 16 ms
18,864 KB
testcase_07 AC 16 ms
18,912 KB
testcase_08 WA -
testcase_09 AC 15 ms
18,908 KB
testcase_10 AC 16 ms
18,868 KB
testcase_11 AC 15 ms
18,888 KB
testcase_12 AC 16 ms
18,884 KB
testcase_13 AC 15 ms
18,876 KB
testcase_14 AC 16 ms
18,984 KB
testcase_15 AC 16 ms
18,960 KB
testcase_16 AC 16 ms
18,916 KB
testcase_17 AC 16 ms
18,884 KB
testcase_18 WA -
testcase_19 AC 16 ms
18,948 KB
testcase_20 AC 16 ms
18,756 KB
testcase_21 AC 15 ms
18,872 KB
testcase_22 AC 16 ms
18,776 KB
testcase_23 WA -
testcase_24 AC 15 ms
18,756 KB
testcase_25 AC 16 ms
18,872 KB
testcase_26 AC 16 ms
18,764 KB
testcase_27 AC 17 ms
18,904 KB
testcase_28 AC 16 ms
18,776 KB
testcase_29 AC 16 ms
18,980 KB
testcase_30 AC 16 ms
18,900 KB
testcase_31 WA -
testcase_32 AC 16 ms
18,956 KB
testcase_33 AC 15 ms
18,780 KB
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$ans = 1;

$s = trim(fgets(STDIN));
$r = strrev($s);
$s = str_split($s);
$r = str_split($r);
$a = array();

scanning($s, $r, $a);
scanning($r, $s, $a);

$h = array_shift($a);
$c = count($h);
if ($c > 2) {
  $ans = $c;
} else if ($c == 2){
  if ($h[0] === $h[1]) {
    $ans = 1;
  }
}
echo $ans . PHP_EOL;

function scanning($from, $to, &$a) {
  for($i=0;$i < count($to); $i++) {
    $o = array_intersect_assoc($from, $to);

    $l = array();
    foreach((array)$o as $k => $v) {
      $l[] = $v;
      if (!isset($o[$k+1])) {
        if (implode($l) === strrev(implode($l)) ) {
          if (strpos(implode($to), implode($l)) !== false) {
            $a[] = $l;
          }
        }
        $l = array();
      }
    }

    array_shift($from);
    array_merge($from);
  }
  arsort($a);
}
0