$sample) { $display_sample_id = $id + 1; $statement .= "\n#### 样例输入 #{$display_sample_id}\n\n"; $statement .= "\n```text\n{$sample[0]}\n```\n\n"; $statement .= "\n#### 样例输出 #{$display_sample_id}\n\n"; $statement .= "\n```text\n{$sample[1]}\n```\n\n"; } $statement .= "\n### 说明/提示\n\n"; $statement .= $problem['hint'] . "\n"; return [ 'title' => "【洛谷 {$problem['pid']}】{$problem['title']}", 'time_limit' => (float)max($problem['limits']['time']) / 1000.0, 'memory_limit' => (float)max($problem['limits']['memory']) / 1024.0, 'statement' => renderMarkdown($statement), 'statement_md' => $statement, ]; } function fetchLuoguProblemBasicInfo($pid) { // ensure validateLuoguProblemId($pid) is true $curl = Curl::init(); $curl->set('CURLOPT_HTTPHEADER', [ 'User-Agent: ' . LUOGU_USER_AGENT, 'Content-Type: application/json', 'Accept: application/json', ]); $curl->url(LUOGU_BASE_URL . '/problem/' . $pid . '?_contentOnly=1'); if ($curl->error()) { throw new Exception('Curl error: ' . $curl->message()); } $data = json_decode($curl->data(), true); return parseLuoguProblemData($data['currentData']['problem']); }