<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<!-- DOMjudge version 3.3.2 -->
<title>Source: s1073</title>
<link rel="shortcut icon" href="../images/favicon.png" type="image/png" />
<link rel="stylesheet" href="../style.css" type="text/css" />
<link rel="stylesheet" href="style_jury.css" type="text/css" />
<script type="text/javascript" src="../js/sorttable.js"></script>
<script type="text/javascript" src="../js/domjudge.js"></script>
</head>
<body>

<h2>Source code for submission s1073</h2>

<p><a href="#diff">Go to diff to previous submission</a></p>

<div class="tabber"><div class="tabbertab"><h2 class="filename"><a name="source0"></a>ants.cpp</h2> 

<pre class="cpp" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339900;">#include &lt;iostream&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339900;">#include &lt;algorithm&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339900;">#include &lt;climits&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">int</span> length, ants, minR<span style="color: #000080;">=</span><span style="color: #0000ff;">INT_MAX</span>, maxL<span style="color: #000080;">=</span><span style="color: #0000ff;">INT_MIN</span>, pos, timeR, size<span style="color: #000080;">=</span><span style="color: #0000dd;">100000</span>, lenR<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span>, lenL<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span>, medL, medR<span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">char</span> dir<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">int</span> left<span style="color: #008000;">&#91;</span>size<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">int</span> right<span style="color: #008000;">&#91;</span>size<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">bool</span> wasRight<span style="color: #000080;">=</span><span style="color: #0000ff;">false</span>, wasLeft<span style="color: #000080;">=</span><span style="color: #0000ff;">false</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span> length <span style="color: #000080;">&gt;&gt;</span> ants<span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>ants<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000dd;">cin</span> <span style="color: #000080;">&gt;&gt;</span> pos <span style="color: #000080;">&gt;&gt;</span> dir<span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>dir<span style="color: #000080;">==</span><span style="color: #FF0000;">'R'</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				wasRight<span style="color: #000080;">=</span><span style="color: #0000ff;">true</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pos<span style="color: #000080;">&lt;</span>minR<span style="color: #008000;">&#41;</span> minR<span style="color: #000080;">=</span>pos<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				right<span style="color: #008000;">&#91;</span>lenR<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>pos<span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				lenR<span style="color: #000040;">++</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000ff;">else</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				wasLeft<span style="color: #000080;">=</span><span style="color: #0000ff;">true</span><span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pos<span style="color: #000080;">&gt;</span>maxL<span style="color: #008000;">&#41;</span> maxL<span style="color: #000080;">=</span>pos<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				left<span style="color: #008000;">&#91;</span>lenL<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>pos<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				lenL<span style="color: #000040;">++</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#125;</span>	</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		timeR<span style="color: #000080;">=</span>length<span style="color: #000040;">-</span>minR<span style="color: #008080;">;</span> <span style="color: #666666;">//cas</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>wasLeft <span style="color: #000040;">&amp;&amp;</span> <span style="color: #000040;">!</span>wasRight<span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The last ant will fall down in &quot;</span> <span style="color: #000080;">&lt;&lt;</span> maxL <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; seconds - started at &quot;</span> <span style="color: #000080;">&lt;&lt;</span> maxL <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>wasLeft <span style="color: #000040;">&amp;&amp;</span> wasRight<span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The last ant will fall down in &quot;</span> <span style="color: #000080;">&lt;&lt;</span> timeR <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; seconds - started at &quot;</span> <span style="color: #000080;">&lt;&lt;</span> minR <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #0000ff;">else</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>timeR<span style="color: #000080;">&lt;</span>maxL<span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #666666;">//cout &lt;&lt; maxL &lt;&lt; &quot; &quot; &lt;&lt; minR &lt;&lt; endl;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				sort<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>left<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span>, <span style="color: #000040;">&amp;</span>left<span style="color: #008000;">&#91;</span>lenL<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>lenL<span style="color: #000080;">==</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medL<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span><span style="color: #008000;">&#40;</span>lenL<span style="color: #000040;">%</span><span style="color:#800080;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medL<span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>lenL<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span> <span style="color: #000040;">+</span> <span style="color: #008000;">&#40;</span>lenL<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span> <span style="color: #000040;">+</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medL<span style="color: #000080;">=</span>lenL<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The last ant will fall down in &quot;</span> <span style="color: #000080;">&lt;&lt;</span> maxL <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; seconds - started at &quot;</span> <span style="color: #000080;">&lt;&lt;</span> left<span style="color: #008000;">&#91;</span>medL<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span>  <span style="color: #FF0000;">&quot;.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>timeR<span style="color: #000080;">&gt;</span>maxL<span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #666666;">//cout &lt;&lt; maxL &lt;&lt; &quot; &quot; &lt;&lt; minR &lt;&lt; endl;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				sort<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>right<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span>, <span style="color: #000040;">&amp;</span>right<span style="color: #008000;">&#91;</span>lenR<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>lenR<span style="color: #000080;">==</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medR<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span><span style="color: #008000;">&#40;</span>lenR<span style="color: #000040;">%</span><span style="color:#800080;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medR<span style="color: #000080;">=</span>lenR<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medR<span style="color: #000080;">=</span>lenR<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The last ant will fall down in &quot;</span> <span style="color: #000080;">&lt;&lt;</span> minR <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; seconds - started at &quot;</span> <span style="color: #000080;">&lt;&lt;</span> right<span style="color: #008000;">&#91;</span>medR<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>timeR<span style="color: #000080;">==</span>maxL<span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#123;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #666666;">//cout &lt;&lt; maxL &lt;&lt; &quot; &quot; &lt;&lt; timeR &lt;&lt; endl;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				sort<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>left<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span>, <span style="color: #000040;">&amp;</span>left<span style="color: #008000;">&#91;</span>lenL<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				sort<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>right<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span>, <span style="color: #000040;">&amp;</span>right<span style="color: #008000;">&#91;</span>lenR<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>lenL<span style="color: #000080;">==</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medL<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span><span style="color: #008000;">&#40;</span>lenL<span style="color: #000040;">%</span><span style="color:#800080;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medL<span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>lenL<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span> <span style="color: #000040;">+</span> <span style="color: #008000;">&#40;</span>lenL<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span> <span style="color: #000040;">+</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medL<span style="color: #000080;">=</span>lenL<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>lenR<span style="color: #000080;">==</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medR<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span><span style="color: #008000;">&#40;</span>lenR<span style="color: #000040;">%</span><span style="color:#800080;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medR<span style="color: #000080;">=</span>lenR<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000ff;">else</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					medR<span style="color: #000080;">=</span>lenR<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The last ant will fall down in &quot;</span> <span style="color: #000080;">&lt;&lt;</span> maxL <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; seconds - started at &quot;</span> <span style="color: #000080;">&lt;&lt;</span> left<span style="color: #008000;">&#91;</span>medL<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; and &quot;</span> <span style="color: #000080;">&lt;&lt;</span> right<span style="color: #008000;">&#91;</span>medR<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;.&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		lenL <span style="color: #000080;">=</span> lenR <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		minR<span style="color: #000080;">=</span><span style="color: #0000ff;">INT_MAX</span><span style="color: #008080;">;</span> maxL<span style="color: #000080;">=</span><span style="color: #0000ff;">INT_MIN</span><span style="color: #008080;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		wasLeft <span style="color: #000080;">=</span> wasRight <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #008000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre></div></div><h2><a name="diff"></a>Diff to submission <a href="956">s956</a></h2>
<div class="tabber"><div class="tabbertab"><h2 class="filename"><a name="diff"></a>ants.cpp</h2>

<pre class="output_text"><span class='diff-del'>--- c4.s956.cteam042.ants.cpp.0.ants.cpp</span>
<span class='diff-add'>+++ c4.s1073.cteam042.ants.cpp.0.ants.cpp</span>
@@ -37,9 +37,9 @@
                 if(wasLeft &amp;&amp; !wasRight)
                 {
<span class='diff-del'>-                        cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; maxL &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; maxL &lt;&lt; endl;</span>
<span class='diff-add'>+                        cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; maxL &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; maxL &lt;&lt; &quot;.&quot; &lt;&lt; endl;</span>
                 }
                 else if(!wasLeft &amp;&amp; wasRight)
                 {
<span class='diff-del'>-                        cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; timeR &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; minR &lt;&lt; endl;</span>
<span class='diff-add'>+                        cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; timeR &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; minR &lt;&lt; &quot;.&quot; &lt;&lt; endl;</span>
                 }
                 else
@@ -49,9 +49,13 @@
                                 //cout &lt;&lt; maxL &lt;&lt; &quot; &quot; &lt;&lt; minR &lt;&lt; endl;
                                 sort(&amp;left[0], &amp;left[lenL]);
<span class='diff-del'>-                                medL=lenL/2;</span>
<span class='diff-add'>+                                if(lenL==0)</span>
<span class='diff-add'>+                                        medL=0;</span>
<span class='diff-add'>+                                else if(!(lenL%2)) </span>
<span class='diff-add'>+                                        medL=((lenL-1)/2 + (lenL-1)/2 + 1)/2;</span>
<span class='diff-add'>+                                else</span>
<span class='diff-add'>+                                        medL=lenL/2;</span>
                                 
<span class='diff-del'>-                                cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; maxL &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; left[medL] &lt;&lt; endl;</span>
<span class='diff-add'>+                                cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; maxL &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; left[medL] &lt;&lt;  &quot;.&quot; &lt;&lt; endl;</span>
                                         
<span class='diff-del'>-                                //cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; maxL &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; maxL &lt;&lt; endl;</span>
                         }
                         else if(timeR&gt;maxL)
@@ -59,6 +63,11 @@
                                 //cout &lt;&lt; maxL &lt;&lt; &quot; &quot; &lt;&lt; minR &lt;&lt; endl;
                                 sort(&amp;right[0], &amp;right[lenR]);
<span class='diff-del'>-                                medR=lenR/2;</span>
<span class='diff-del'>-                                cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; minR &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; right[medR] &lt;&lt; endl;</span>
<span class='diff-add'>+                                if(lenR==0)</span>
<span class='diff-add'>+                                        medR=0;</span>
<span class='diff-add'>+                                else if(!(lenR%2))</span>
<span class='diff-add'>+                                        medR=lenR/2;</span>
<span class='diff-add'>+                                else</span>
<span class='diff-add'>+                                        medR=lenR/2;</span>
<span class='diff-add'>+                                cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; minR &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; right[medR] &lt;&lt; &quot;.&quot; &lt;&lt; endl;</span>
                         }
                         else if(timeR==maxL)
@@ -67,7 +76,21 @@
                                 sort(&amp;left[0], &amp;left[lenL]);
                                 sort(&amp;right[0], &amp;right[lenR]);
<span class='diff-del'>-                                medR=lenR/2;</span>
<span class='diff-del'>-                                medL=lenL/2;</span>
<span class='diff-del'>-                                cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; maxL &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; left[medL] &lt;&lt; &quot; and &quot; &lt;&lt; right[medR] &lt;&lt; endl;</span>
<span class='diff-add'>+                                </span>
<span class='diff-add'>+                                if(lenL==0)</span>
<span class='diff-add'>+                                        medL=0;</span>
<span class='diff-add'>+                                else if(!(lenL%2)) </span>
<span class='diff-add'>+                                        medL=((lenL-1)/2 + (lenL-1)/2 + 1)/2;</span>
<span class='diff-add'>+                                else</span>
<span class='diff-add'>+                                        medL=lenL/2;</span>
<span class='diff-add'>+                                </span>
<span class='diff-add'>+                                </span>
<span class='diff-add'>+                                if(lenR==0)</span>
<span class='diff-add'>+                                        medR=0;</span>
<span class='diff-add'>+                                else if(!(lenR%2))</span>
<span class='diff-add'>+                                        medR=lenR/2;</span>
<span class='diff-add'>+                                else</span>
<span class='diff-add'>+                                        medR=lenR/2;</span>
<span class='diff-add'>+                                </span>
<span class='diff-add'>+                                cout &lt;&lt; &quot;The last ant will fall down in &quot; &lt;&lt; maxL &lt;&lt; &quot; seconds - started at &quot; &lt;&lt; left[medL] &lt;&lt; &quot; and &quot; &lt;&lt; right[medR] &lt;&lt; &quot;.&quot; &lt;&lt; endl;</span>
                         }
                 }
</pre>

</div></div>
</body>
</html>
