結果

問題 No.548 国士無双
ユーザー ShinichiUShinichiU
提出日時 2017-07-29 15:17:57
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 770 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 32,416 KB
実行使用メモリ 32,604 KB
最終ジャッジ日時 2023-10-17 16:02:34
合計ジャッジ時間 1,934 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
32,540 KB
testcase_01 AC 38 ms
32,540 KB
testcase_02 AC 40 ms
32,540 KB
testcase_03 AC 41 ms
32,540 KB
testcase_04 AC 39 ms
32,540 KB
testcase_05 AC 39 ms
32,540 KB
testcase_06 AC 38 ms
32,540 KB
testcase_07 AC 39 ms
32,540 KB
testcase_08 AC 40 ms
32,540 KB
testcase_09 AC 39 ms
32,540 KB
testcase_10 AC 38 ms
32,540 KB
testcase_11 AC 38 ms
32,540 KB
testcase_12 AC 39 ms
32,540 KB
testcase_13 AC 40 ms
32,540 KB
testcase_14 AC 39 ms
32,540 KB
testcase_15 AC 39 ms
32,540 KB
testcase_16 AC 38 ms
32,540 KB
testcase_17 AC 38 ms
32,540 KB
testcase_18 AC 39 ms
32,540 KB
testcase_19 AC 37 ms
32,540 KB
testcase_20 WA -
testcase_21 AC 39 ms
32,540 KB
testcase_22 AC 39 ms
32,604 KB
testcase_23 AC 39 ms
32,540 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

#!/usr/bin/env php
<?php

$baseStr = 'abcdefghijklm';
$bases = [];
for ($j = 0; $j < strlen($baseStr); $j++)
{
  $bases[] = $baseStr[$j];
}

$str = trim(fgets(STDIN));
$arr = [];
for ($i = 0; $i < 13; $i++)
{
  if (array_key_exists($str[$i], $arr))
  {
    $arr[$str[$i]]++;
  }
  else
  {
    $arr[$str[$i]] = 1;
  }
}

$max = max($arr);
if ($max > 2)
{
  ng();
}

function add_check($str, $arr)
{
  if (!isset($arr[$str]))
  {
    return true;
  }

  $max = max($arr);

  if ($arr[$str] != 2 && $max == $arr[$str])
  {
    return true;
  }

  return false;
}

$isOk = false;
foreach ($bases as $base)
{
  if (add_check($base, $arr))
  {
    $isOk = true;
    echo $base, PHP_EOL;
  }
}

if (!$isOk)
{
  ng();
}

function ng()
{
  echo 'Impossible', PHP_EOL;
  exit;
}
0