Files
usaco/site/internal/statement/testdata/usaco.html
T
adamfandClaude Opus 5.5 995b44a57a
Test and publish the site / publish (push) Successful in 8m15s
Test and publish the site / test (push) Successful in 5m51s
Add an Explain button that has Claude explain a problem
When stuck, the admin can ask Claude for an intuitive explanation of a
problem. It is committed as explain.md and shown as folded sections, so
the reader opens only as much as they need: the key observation, hints
that get stronger, the approach, a walkthrough with an SVG diagram per
step, complexity, pitfalls and a pseudocode sketch.

- internal/claude: streamed call with a JSON-schema reply, high effort,
  the server-side refusal fallback, fixed error messages and logged
  token usage. CLAUDE_API_KEY and CLAUDE_MODEL (default claude-opus-5-5);
  without a key only this feature is off.
- internal/explain: the prompt, the schema, rendering to markdown, and
  a per-problem job tracker. The request starts a job and the page polls,
  since a call outlasts nginx's 120s timeout.
- internal/statement: fetches statements from LeetCode's GraphQL API and
  USACO's problem pages. Others (Codeforces is behind Cloudflare) are
  pasted.
- problem.md holds the statement, editable from the meta editor and
  shown only to the admin. Diagrams are sanitized with DOMPurify.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 20:38:15 +01:00

250 lines
8.4 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>USACO</title>
<link rel="stylesheet" type="text/css" href="current/usaco.css?v=2.0">
<script src="current/js/jquery.min.js"></script>
<script src="https://d3js.org/d3.v3.min.js"></script>
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {
scale: 85,
preferredFont: "STIX"
},
tex2jax: {
inlineMath: [['$','$'],['\\(','\\)']],
processEscapes: true,
skipTags: ['pre'],
processClass: "mathjax",
ignoreClass: "no-mathjax"
}
});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</head>
<body class="no-mathjax">
<div align="center">
<div class="shadow1">
<div class="content">
<a href="index.php"><img src="current/images/usaco_logo.png" height="130px" border="0px" /></a>
<div class="navbar" align="left" border="10px">
<ul>
<li><a href="index.php">Overview</a></li>
<li><a href="index.php?page=details">Details / FAQ</a></li>
<li><a href="index.php?page=training">Training</a></li>
<li><a href="index.php?page=history">History</a></li>
<li><a href="index.php?page=resources">Resources</a></li>
</ul>
</div><br/>
<div style="position:relative; float:left; left:10px; top:-50px; width:550px;">
<div class="panel">
<h2> USACO 2016 US Open Contest, Silver </h2>
<h2> Problem 3. Closing the Farm </h2>
</div>
</div>
<div align="right" style="position:relative; float:right; right:30px; top:-40px; width:350px;">
<button style="margin-bottom:6px;" type="button" onClick="window.location='index.php?page=open16results';">Return to Problem List</button><br style="padding-top:6px"/>
Contest has ended.
</div>
<br style="clear:both" />
<div id="last-status" style="padding:10px; position:relative; float:left; left:30px; top:-45px; width:820px; border:1px solid black; background-color:#FFF; "
data-response-code="-1" data-sid="-1">
<img src="current/images/ajax.gif"/> <p style="display:inline;"> <b>Log in to allow submissions in analysis mode</b></p>
<div id="trial-information"></div>
<p style="text-align:left;" class="mono prewrap output-data"></p>
</div>
<br style="clear:both" />
<div align="right" style="position:relative; float:right; right:40px; top:-93px; width:350px; z-index:2; padding:0px;">
<form style="padding-top:60px;" action="">
<select name="lang" style="background-color:#eee;" id="choose-language">
<option value='en' selected='yes'>English (en)</option>
<option value='hy'>Armenian (hy)</option>
<option value='bg'>Bulgarian (bg)</option>
<option value='fr'>French (fr)</option>
<option value='ru'>Russian (ru)</option>
<option value='es'>Spanish (es)</option>
</select>
</form>
</div>
<div align="left" style="position:relative; float:left; left:30px; top:-100px; width:840px; z-index:1;">
<div align="left" class="problem-text" style='width:800px; padding-top:10px;'>
<span id="probtext-text" class="mathjax">Farmer John and his cows are planning to leave town for a long vacation, and so
FJ wants to temporarily close down his farm to save money in the meantime.
<p>The farm consists of $N$ barns connected with $M$ bidirectional paths between
some pairs of barns ($1 \leq N, M \leq 3000$). To shut the farm down, FJ plans
to close one barn at a time. When a barn closes, all paths adjacent to that
barn also close, and can no longer be used.
<p>FJ is interested in knowing at each point in time (initially, and after each
closing) whether his farm is "fully connected" -- meaning that it is possible to
travel from any open barn to any other open barn along an appropriate series of
paths. Since FJ's farm is initially in somewhat in a state of disrepair, it may
not even start out fully connected.
<p><div class='prob-in-spec'><h4>INPUT FORMAT (file closing.in):</h4>
The first line of input contains $N$ and $M$. The next $M$ lines each describe a
path in terms of the pair of barns it connects (barns are conveniently numbered
$1 \ldots N$). The final $N$ lines give a permutation of $1 \ldots N$
describing the order in which the barns will be closed.
</div>
<p><div class='prob-out-spec'><h4>OUTPUT FORMAT (file closing.out):</h4>
The output consists of $N$ lines, each containing "YES" or "NO". The first line
indicates whether the initial farm is fully connected, and line $i+1$ indicates
whether the farm is fully connected after the $i$th closing.
</div>
<p><h4>SAMPLE INPUT:</h4><pre class='in'>
4 3
1 2
2 3
3 4
3
4
1
2
</pre><h4>SAMPLE OUTPUT:</h4> <pre class='out'>
YES
NO
YES
YES
</pre>
<p>
<p>Problem credits: Yang Liu
</span>
</div>
Contest has ended. No further submissions allowed.
</div>
<div align="left" style="position:relative; float:left; left:30px; top:-70px; width:840px;">
</div>
<br style="clear:both" />
<script>
var retries = 100, timeout = 1000;
function postback()
{
var sid = $('#last-status').data('sid'); if (sid == -1) return;
$.post('current/tpcm/status-update.php', { sid: sid }, update_response, 'json');
}
function update_response(s)
{
// only try a limited number of times
if (--retries < 0) return;
// if there is xml data, update the DOM
if (s != null)
{
$('#last-status img').attr("src","current/images/medal_none.png");
if (parseInt(s.cd) <= -8 && s.sc == 'status-working') { $('#last-status img').attr("src","current/images/ajax.gif"); }
// change class and text of the response box
$('#last-status').removeClass().addClass(s.sc);
$('#last-status p').text(s.sr);
// change the response code of the data section
$('#last-status').data('response-code', parseInt(s.cd));
$('#last-status .output-data').hide();
if (s.output != null)
{
$('#last-status .output-data').show().text(s.output);
// if the status is in a "working" state, keep checking
if (parseInt($('#last-status').data('response-code')) <= -8)
{ setTimeout(postback, timeout); timeout *= 1.1; }
return;
}
if (s.jd != null && s.jd.length != 0)
$('#trial-information').html(s.jd);
}
// if the status is in a "working" state, keep checking
if (parseInt($('#last-status').data('response-code')) <= -8)
{ setTimeout(postback, timeout); timeout *= 1.1; }
}
$(document).ready(function(){
$('#last-status .output-data').hide();
$('#last-status img').attr("src","current/images/medal_none.png");
if ($('#last-status').length) postback();
$('.masterTooltip').hover(function(){
// Hover over code
var title = $(this).attr('title');
$(this).data('tipText', title).removeAttr('title');
$('<p class="tooltip"></p>').text(title).appendTo('body').fadeIn('fast');
}, function() {
// Hover out code
$(this).attr('title', $(this).data('tipText'));
$('.tooltip').remove();
}).mousemove(function(e) {
var mousex = e.pageX + 20; //Get X coordinates
var mousey = e.pageY + 10; //Get Y coordinates
$('.tooltip').css({ top: mousey, left: mousex })
});
});
$('#choose-language').change(function(e){
window.location = "index.php?page=viewproblem2&cpid=644&lang=" + $(this).val();
});
</script>
</div>
</div>
</div>
<br style="clear:both" />
<script>(function(){function c(){var b=a.contentDocument||(a.contentWindow&&a.contentWindow.document);if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'a4d22a230b2cc51c',t:'MTc5MjQzNzg4Mw=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body>
</html>