結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-09-26 20:48:34 |
| 言語 | PHP (843.2) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 793 bytes |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 32,400 KB |
| 実行使用メモリ | 32,784 KB |
| 最終ジャッジ日時 | 2024-12-23 11:59:06 |
| 合計ジャッジ時間 | 3,053 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 32 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
$ans = 0;
$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, ""))) {
$a[] = $l;
}
}
$l = array();
}
}
array_shift($from);
array_merge($from);
}
arsort($a);
}