Skip to content

Commit

Permalink
Merge pull request #5 from azhar25git/patch-1
Browse files Browse the repository at this point in the history
Updated accordingly with current  question and pattern
  • Loading branch information
sword-jin authored Jun 4, 2022
2 parents 78349c8 + fd590b1 commit a0e6943
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions Algorithm/Implementation/13-acm-icpc-team.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

0 comments on commit a0e6943

Please sign in to comment.