<?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: s1010</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 s1010</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>cockchaf.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;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;cctype&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;cmath&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;complex&gt;</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: #339900;">#include &lt;cstdio&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;cstring&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;iomanip&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;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;list&gt;</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: #339900;">#include &lt;map&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;queue&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;set&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;sstream&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;stack&gt;</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: #339900;">#include &lt;string&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;utility&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;vector&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: 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;">using</span> <span style="color: #0000ff;">namespace</span> std<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: #339900;">#define DEBUG(x) cerr &lt;&lt; &quot;&gt;&gt;&gt; &quot; &lt;&lt; #x &lt;&lt; &quot; : &quot; &lt;&lt; x &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;"><span style="color: #339900;">#define REP(i,a) for (int i = 0; i &lt; (a); ++i)</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;">#define FOR(i,a,b) for (int i = (a); i &lt;= (b); ++i)</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;">#define FORD(i,a,b) for (int i = (a); i &gt;= (b); --i)</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;">inline</span> <span style="color: #0000ff;">bool</span> EQ<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">double</span> a, <span style="color: #0000ff;">double</span> b<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">fabs</span><span style="color: #008000;">&#40;</span>a<span style="color: #000040;">-</span>b<span style="color: #008000;">&#41;</span> <span style="color: #000080;">&lt;</span> <span style="color:#800080;">1e-9</span><span style="color: #008080;">;</span> <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;">&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;">const</span> <span style="color: #0000ff;">int</span> INF <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #0000dd;">29</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;">typedef</span> <span style="color: #0000ff;">long</span> <span style="color: #0000ff;">long</span> ll<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: #666666;">//////////////////////////////////</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: #339900;">#define MAXN 1100</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;">#define MAXC 2200</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;">#define MAXD 10100</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> N<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;">double</span> S, T<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;">map<span style="color: #000080;">&lt;</span>ll, <span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> n2i_map<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;">ll i2n_map<span style="color: #008000;">&#91;</span>MAXC<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> iCnt<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;">vector<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> way<span style="color: #008000;">&#91;</span>MAXC<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> visited<span style="color: #008000;">&#91;</span>MAXC<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>MAXC<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;">double</span> totDist<span style="color: #008000;">&#91;</span>MAXC<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>MAXC<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;">typedef</span> priority_queue<span style="color: #000080;">&lt;</span>pair<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">double</span>, pair<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span>, <span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> <span style="color: #000080;">&gt;</span> <span style="color: #000080;">&gt;</span> qType<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;">qType toVisit<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: #0000ff;">void</span> clear_all<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;">  n2i_map.<span style="color: #007788;">clear</span><span style="color: #008000;">&#40;</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;">  iCnt <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;">  REP<span style="color: #008000;">&#40;</span>i,MAXC<span style="color: #008000;">&#41;</span> way<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">clear</span><span style="color: #008000;">&#40;</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;">  REP<span style="color: #008000;">&#40;</span>i,MAXC<span style="color: #008000;">&#41;</span> REP<span style="color: #008000;">&#40;</span>j, MAXC<span style="color: #008000;">&#41;</span> visited<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <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;">  REP<span style="color: #008000;">&#40;</span>i,MAXC<span style="color: #008000;">&#41;</span> REP<span style="color: #008000;">&#40;</span>j, MAXC<span style="color: #008000;">&#41;</span> totDist<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color:#800080;">1.0</span> <span style="color: #000040;">/</span> <span style="color:#800080;">0.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;">  toVisit <span style="color: #000080;">=</span> qType<span style="color: #008000;">&#40;</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: #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: 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;">int</span> p2i<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y, <span style="color: #0000ff;">int</span> z<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;">  ll p <span style="color: #000080;">=</span> x<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;">  p <span style="color: #000040;">*</span><span style="color: #000080;">=</span> MAXD<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;">  p <span style="color: #000040;">+</span><span style="color: #000080;">=</span> y<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;">  p <span style="color: #000040;">*</span><span style="color: #000080;">=</span> MAXD<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;">  p <span style="color: #000040;">+</span><span style="color: #000080;">=</span> z<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;">  map<span style="color: #000080;">&lt;</span>ll, <span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span><span style="color: #008080;">::</span><span style="color: #007788;">iterator</span> iter <span style="color: #000080;">=</span> n2i_map.<span style="color: #007788;">find</span><span style="color: #008000;">&#40;</span>p<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>iter <span style="color: #000040;">!</span><span style="color: #000080;">=</span> n2i_map.<span style="color: #007788;">end</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">return</span> iter<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>second<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;">  n2i_map<span style="color: #008000;">&#91;</span>p<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> iCnt<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;">  i2n_map<span style="color: #008000;">&#91;</span>iCnt<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> p<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;">return</span> iCnt<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;">&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;">ll i2n<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<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;">  <span style="color: #0000ff;">return</span> i2n_map<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</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><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> n2x<span style="color: #008000;">&#40;</span>ll n<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0000ff;">return</span> <span style="color: #008000;">&#40;</span>n <span style="color: #000040;">/</span> MAXD<span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> MAXD<span style="color: #008080;">;</span> <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;">int</span> n2y<span style="color: #008000;">&#40;</span>ll n<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0000ff;">return</span> <span style="color: #008000;">&#40;</span>n <span style="color: #000040;">/</span> MAXD<span style="color: #008000;">&#41;</span> <span style="color: #000040;">%</span> MAXD<span style="color: #008080;">;</span> <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;">int</span> n2z<span style="color: #008000;">&#40;</span>ll n<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0000ff;">return</span> n <span style="color: #000040;">%</span> MAXD<span style="color: #008080;">;</span> <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;">&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;">double</span> dist<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i1, <span style="color: #0000ff;">int</span> i2<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;">  ll n1 <span style="color: #000080;">=</span> i2n<span style="color: #008000;">&#40;</span>i1<span style="color: #008000;">&#41;</span>, n2 <span style="color: #000080;">=</span> i2n<span style="color: #008000;">&#40;</span>i2<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;">double</span> x1 <span style="color: #000080;">=</span> n2x<span style="color: #008000;">&#40;</span>n1<span style="color: #008000;">&#41;</span>, y1 <span style="color: #000080;">=</span> n2y<span style="color: #008000;">&#40;</span>n1<span style="color: #008000;">&#41;</span>, z1 <span style="color: #000080;">=</span> n2z<span style="color: #008000;">&#40;</span>n1<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;">double</span> x2 <span style="color: #000080;">=</span> n2x<span style="color: #008000;">&#40;</span>n2<span style="color: #008000;">&#41;</span>, y2 <span style="color: #000080;">=</span> n2y<span style="color: #008000;">&#40;</span>n2<span style="color: #008000;">&#41;</span>, z2 <span style="color: #000080;">=</span> n2z<span style="color: #008000;">&#40;</span>n2<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;">double</span> dx <span style="color: #000080;">=</span> x1<span style="color: #000040;">-</span>x2, dy <span style="color: #000080;">=</span> y1<span style="color: #000040;">-</span>y2, dz <span style="color: #000080;">=</span> z1<span style="color: #000040;">-</span>z2<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;">return</span> <span style="color: #0000dd;">sqrt</span><span style="color: #008000;">&#40;</span>dx<span style="color: #000040;">*</span>dx<span style="color: #000040;">+</span>dy<span style="color: #000040;">*</span>dy<span style="color: #000040;">+</span>dz<span style="color: #000040;">*</span>dz<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: #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;"><span style="color: #0000ff;">double</span> distT<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i1, <span style="color: #0000ff;">int</span> i2<span style="color: #008000;">&#41;</span> <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: #0000ff;">return</span> dist<span style="color: #008000;">&#40;</span>i1, i2<span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> S<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;">&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;">double</span> ang<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i1, <span style="color: #0000ff;">int</span> d1, <span style="color: #0000ff;">int</span> i2, <span style="color: #0000ff;">int</span> d2<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;">  ll n1i <span style="color: #000080;">=</span> i2n<span style="color: #008000;">&#40;</span>i1<span style="color: #008000;">&#41;</span>, n2i <span style="color: #000080;">=</span> i2n<span style="color: #008000;">&#40;</span>i2<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;">  ll n1d <span style="color: #000080;">=</span> i2n<span style="color: #008000;">&#40;</span>d1<span style="color: #008000;">&#41;</span>, n2d <span style="color: #000080;">=</span> i2n<span style="color: #008000;">&#40;</span>d2<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;">double</span> x1i <span style="color: #000080;">=</span> n2x<span style="color: #008000;">&#40;</span>n1i<span style="color: #008000;">&#41;</span>, y1i <span style="color: #000080;">=</span> n2y<span style="color: #008000;">&#40;</span>n1i<span style="color: #008000;">&#41;</span>, z1i <span style="color: #000080;">=</span> n2z<span style="color: #008000;">&#40;</span>n1i<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;">double</span> x2i <span style="color: #000080;">=</span> n2x<span style="color: #008000;">&#40;</span>n2i<span style="color: #008000;">&#41;</span>, y2i <span style="color: #000080;">=</span> n2y<span style="color: #008000;">&#40;</span>n2i<span style="color: #008000;">&#41;</span>, z2i <span style="color: #000080;">=</span> n2z<span style="color: #008000;">&#40;</span>n2i<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;">double</span> x1d <span style="color: #000080;">=</span> n2x<span style="color: #008000;">&#40;</span>n1d<span style="color: #008000;">&#41;</span>, y1d <span style="color: #000080;">=</span> n2y<span style="color: #008000;">&#40;</span>n1d<span style="color: #008000;">&#41;</span>, z1d <span style="color: #000080;">=</span> n2z<span style="color: #008000;">&#40;</span>n1d<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;">double</span> x2d <span style="color: #000080;">=</span> n2x<span style="color: #008000;">&#40;</span>n2d<span style="color: #008000;">&#41;</span>, y2d <span style="color: #000080;">=</span> n2y<span style="color: #008000;">&#40;</span>n2d<span style="color: #008000;">&#41;</span>, z2d <span style="color: #000080;">=</span> n2z<span style="color: #008000;">&#40;</span>n2d<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;">double</span> dx1 <span style="color: #000080;">=</span> x1d<span style="color: #000040;">-</span>x1i, dy1 <span style="color: #000080;">=</span> y1d<span style="color: #000040;">-</span>y1i, dz1 <span style="color: #000080;">=</span> z1d<span style="color: #000040;">-</span>z1i<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;">double</span> dx2 <span style="color: #000080;">=</span> x2d<span style="color: #000040;">-</span>x2i, dy2 <span style="color: #000080;">=</span> y2d<span style="color: #000040;">-</span>y2i, dz2 <span style="color: #000080;">=</span> z2d<span style="color: #000040;">-</span>z2i<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;">double</span> num <span style="color: #000080;">=</span> dx1<span style="color: #000040;">*</span>dx2 <span style="color: #000040;">+</span> dy1<span style="color: #000040;">*</span>dy2 <span style="color: #000040;">+</span> dz1<span style="color: #000040;">*</span>dz2<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;">double</span> den <span style="color: #000080;">=</span> dist<span style="color: #008000;">&#40;</span>i1, d1<span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> dist<span style="color: #008000;">&#40;</span>i2, d2<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;">return</span> <span style="color: #0000dd;">acos</span><span style="color: #008000;">&#40;</span>num <span style="color: #000040;">/</span> den<span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> <span style="color:#800080;">180.0</span> <span style="color: #000040;">/</span> M_PI<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><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;">double</span> angT<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i1, <span style="color: #0000ff;">int</span> d1, <span style="color: #0000ff;">int</span> i2, <span style="color: #0000ff;">int</span> d2<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;">  <span style="color: #0000ff;">return</span> ang<span style="color: #008000;">&#40;</span>i1, d1, i2, d2<span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> T<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;">&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;">  <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">scanf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%d%lf%lf&quot;</span>, <span style="color: #000040;">&amp;</span>N, <span style="color: #000040;">&amp;</span>S, <span style="color: #000040;">&amp;</span>T<span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #0000dd;">3</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;">    clear_all<span style="color: #008000;">&#40;</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;">int</span> Si, Fi<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;">&#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;">int</span> x, y, z<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;">scanf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%d%d%d&quot;</span>, <span style="color: #000040;">&amp;</span>x, <span style="color: #000040;">&amp;</span>y, <span style="color: #000040;">&amp;</span>z<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;">      Si <span style="color: #000080;">=</span> p2i<span style="color: #008000;">&#40;</span>x, y, z<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: #0000dd;">scanf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%d%d%d&quot;</span>, <span style="color: #000040;">&amp;</span>x, <span style="color: #000040;">&amp;</span>y, <span style="color: #000040;">&amp;</span>z<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;">      Fi <span style="color: #000080;">=</span> p2i<span style="color: #008000;">&#40;</span>x, y, z<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: #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;">    REP<span style="color: #008000;">&#40;</span>i,N<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;">      <span style="color: #0000ff;">int</span> x, y, z<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;">scanf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%d%d%d&quot;</span>, <span style="color: #000040;">&amp;</span>x, <span style="color: #000040;">&amp;</span>y, <span style="color: #000040;">&amp;</span>z<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;">int</span> i1 <span style="color: #000080;">=</span> p2i<span style="color: #008000;">&#40;</span>x, y, z<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: #0000dd;">scanf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%d%d%d&quot;</span>, <span style="color: #000040;">&amp;</span>x, <span style="color: #000040;">&amp;</span>y, <span style="color: #000040;">&amp;</span>z<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;">int</span> i2 <span style="color: #000080;">=</span> p2i<span style="color: #008000;">&#40;</span>x, y, z<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;">      way<span style="color: #008000;">&#91;</span>i1<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">push_back</span><span style="color: #008000;">&#40;</span>i2<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;">      way<span style="color: #008000;">&#91;</span>i2<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">push_back</span><span style="color: #008000;">&#40;</span>i1<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: #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;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> jj <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> jj <span style="color: #000080;">&lt;</span> way<span style="color: #008000;">&#91;</span>Si<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #000040;">++</span>jj<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;">      <span style="color: #0000ff;">int</span> toD <span style="color: #000080;">=</span> way<span style="color: #008000;">&#91;</span>Si<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>jj<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;">      totDist<span style="color: #008000;">&#91;</span>Si<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>toD<span style="color: #008000;">&#93;</span> <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;">      toVisit.<span style="color: #007788;">push</span><span style="color: #008000;">&#40;</span>make_pair<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span>, make_pair<span style="color: #008000;">&#40;</span>Si, toD<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</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: #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;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>toVisit.<span style="color: #007788;">empty</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</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;">      <span style="color: #666666;">//printf(&quot;dist %lf\n&quot;, -toVisit.top().first);</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;">      pair<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span>, <span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> pr <span style="color: #000080;">=</span> toVisit.<span style="color: #007788;">top</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">second</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;">      toVisit.<span style="color: #007788;">pop</span><span style="color: #008000;">&#40;</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;">int</span> at <span style="color: #000080;">=</span> pr.<span style="color: #007788;">first</span>, d <span style="color: #000080;">=</span> pr.<span style="color: #007788;">second</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>at <span style="color: #000080;">==</span> Fi<span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">break</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>visited<span style="color: #008000;">&#91;</span>at<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">continue</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: #666666;">//printf(&quot;vis %d %d\n&quot;, at, d);</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;">      visited<span style="color: #008000;">&#91;</span>at<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span> <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;">double</span> dT <span style="color: #000080;">=</span> distT<span style="color: #008000;">&#40;</span>at, d<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>d <span style="color: #000080;">==</span> Fi<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;">        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>totDist<span style="color: #008000;">&#91;</span>at<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #000040;">+</span>dT <span style="color: #000080;">&lt;</span> totDist<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</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;">          totDist<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> totDist<span style="color: #008000;">&#91;</span>at<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #000040;">+</span>dT<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;">          toVisit.<span style="color: #007788;">push</span><span style="color: #008000;">&#40;</span>make_pair<span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span>totDist<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span>, make_pair<span style="color: #008000;">&#40;</span>d, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</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: #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;">continue</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;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> jj <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> jj <span style="color: #000080;">&lt;</span> way<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #000040;">++</span>jj<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;">        <span style="color: #0000ff;">int</span> toD <span style="color: #000080;">=</span> way<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>jj<span style="color: #008000;">&#93;</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>visited<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>toD<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">continue</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: #666666;">//printf(&quot;  try %d %d\n&quot;, d, toD);</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;">double</span> aT <span style="color: #000080;">=</span> angT<span style="color: #008000;">&#40;</span>at, d, d, toD<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>totDist<span style="color: #008000;">&#91;</span>at<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #000040;">+</span>dT<span style="color: #000040;">+</span>aT <span style="color: #000080;">&lt;</span> totDist<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>toD<span style="color: #008000;">&#93;</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;">          <span style="color: #666666;">//printf(&quot;    go %d %d\n&quot;, d, toD);</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;">          totDist<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>toD<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> totDist<span style="color: #008000;">&#91;</span>at<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #000040;">+</span>dT<span style="color: #000040;">+</span>aT<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;">          toVisit.<span style="color: #007788;">push</span><span style="color: #008000;">&#40;</span>make_pair<span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span>totDist<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>toD<span style="color: #008000;">&#93;</span>, make_pair<span style="color: #008000;">&#40;</span>d, toD<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</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: #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;">    <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: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, totDist<span style="color: #008000;">&#91;</span>Fi<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><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: #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;">return</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: #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="906">s906</a></h2>
<div class="tabber"><div class="tabbertab"><h2 class="filename"><a name="diff"></a>cockchaf.cpp</h2>

<pre class="output_text"><span class='diff-del'>--- c4.s906.cteam002.cockchaf.cpp.0.cockchaf.cpp</span>
<span class='diff-add'>+++ c4.s1010.cteam002.cockchaf.cpp.0.cockchaf.cpp</span>
@@ -41,5 +41,5 @@
 bool visited[MAXC][MAXC];
 double totDist[MAXC][MAXC];
<span class='diff-del'>-typedef priority_queue&lt;pair&lt;int, pair&lt;int, int&gt; &gt; &gt; qType;</span>
<span class='diff-add'>+typedef priority_queue&lt;pair&lt;double, pair&lt;int, int&gt; &gt; &gt; qType;</span>
 qType toVisit;
 
@@ -130,4 +130,5 @@
     }
     while (!toVisit.empty()) {
<span class='diff-add'>+      //printf(&quot;dist %lf\n&quot;, -toVisit.top().first);</span>
       pair&lt;int, int&gt; pr = toVisit.top().second;
       toVisit.pop();
@@ -135,4 +136,5 @@
       if (at == Fi) break;
       if (visited[at][d]) continue;
<span class='diff-add'>+      //printf(&quot;vis %d %d\n&quot;, at, d);</span>
       visited[at][d] = true;
       double dT = distT(at, d);
@@ -147,6 +149,8 @@
         int toD = way[d][jj];
         if (visited[d][toD]) continue;
<span class='diff-del'>-        double aT = (d==Fi) ? 0 : angT(at, d, d, toD);</span>
<span class='diff-add'>+        //printf(&quot;  try %d %d\n&quot;, d, toD);</span>
<span class='diff-add'>+        double aT = angT(at, d, d, toD);</span>
         if (totDist[at][d]+dT+aT &lt; totDist[d][toD]) {
<span class='diff-add'>+          //printf(&quot;    go %d %d\n&quot;, d, toD);</span>
           totDist[d][toD] = totDist[at][d]+dT+aT;
           toVisit.push(make_pair(-totDist[d][toD], make_pair(d, toD)));
</pre>

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