Example #1
0
 function readNext($num)
 {
     $result = array();
     for ($i = 0; $i < $num; $i++) {
         if ($this->mode == self::OPEN_MODE_PEER) {
             $result[] = read_do($this->peer);
         } else {
             $result[] = read_array();
         }
     }
     return $result;
 }
Example #2
0
function ctdl_msgs($mode, $count)
{
    global $clientsocket;
    serv_puts("MSGS " . $mode . "|" . $count);
    $responses = read_array();
    dbgprintf_wrapout(print_r($responses, true), false);
    $response = array_shift($responses);
    $num_msgs = count($responses);
    if (substr($response, 0, 1) != "1") {
        return array(0, substr($response, 4), NULL);
    }
    if (CITADEL_DEBUG_CITPROTO == 1) {
        dbgprintf_wrapout("found " . $num_msgs . " messages.", true);
    }
    return array($num_msgs, $response, $responses);
}
Example #3
0
<?php

function read_array()
{
    $a = split(' ', fgets(STDIN));
    return array_map('intval', $a);
}
list($n, $m) = read_array();
$a = array();
for ($i = 0; $i < $m; ++$i) {
    $b = read_array();
    array_shift($b);
    foreach ($b as $j) {
        $a[$j] = $i;
    }
}
list($q) = read_array();
$c = array();
for ($i = 0; $i < $q; ++$i) {
    list($x, $y) = read_array();
    if ($a[$x] === $a[$y]) {
        $c[$x] = 1;
        $c[$y] = 1;
    }
}
echo count($c) . "\n";