diff --git a/Algorithm/Implementation/13-acm-icpc-team.php b/Algorithm/Implementation/13-acm-icpc-team.php index 2f211c6..fd28037 100755 --- a/Algorithm/Implementation/13-acm-icpc-team.php +++ b/Algorithm/Implementation/13-acm-icpc-team.php @@ -32,20 +32,36 @@ // just soso.. -$highest = -1; -$bestTeam = 0; - -for ($i=0; $i < $n - 1; $i++) { - for ($j=$i + 1; $j < $n; $j++) { - $temp = substr_count($topic[$i] | $topic[$j], "1"); - if ($temp > $highest) { - $highest = $temp; - $bestTeam = 1; - } else if ($temp == $highest) { - $bestTeam ++; - } - } -} +// $highest = -1; +// $bestTeam = 0; + +// for ($i=0; $i < $n - 1; $i++) { +// for ($j=$i + 1; $j < $n; $j++) { +// $temp = substr_count($topic[$i] | $topic[$j], "1"); +// if ($temp > $highest) { +// $highest = $temp; +// $bestTeam = 1; +// } else if ($temp == $highest) { +// $bestTeam ++; +// } +// } +// } + +// echo $highest . PHP_EOL; +// echo $bestTeam . PHP_EOL; -echo $highest . PHP_EOL; -echo $bestTeam . PHP_EOL; + $highest = -1; + $bestTeam = 0; + $n = $topic; + for ($i=0; $i < count($n) - 1; $i++) { + for ($j=$i + 1; $j < count($n); $j++) { + $temp = substr_count($topic[$i] | $topic[$j], "1"); + if ($temp > $highest) { + $highest = $temp; + $bestTeam = 1; + } else if ($temp == $highest) { + $bestTeam ++; + } + } + } + return [$highest,$bestTeam];