ContestResult OLCLeague::CalculateResult() const { ContestResult result; if (!solution[4].IsDefined()) { result.Reset(); return result; } result.time = fixed(solution[4].DeltaTime(solution[0])); result.distance = fixed(0); for (unsigned i = 0; i < 4; ++i) result.distance += solution[i].DistanceTo(solution[i + 1].GetLocation()); result.score = ApplyShiftedHandicap(result.distance / 2500); return result; }
void PrintHelper::print(const ContestResult& score) { std::cout << "# score " << score.score << "\n"; std::cout << "# distance " << score.distance/fixed(1000) << " (km)\n"; std::cout << "# speed " << score.GetSpeed() * fixed(3.6) << " (kph)\n"; std::cout << "# time " << score.time << " (sec)\n"; }
static void WriteContest(TextWriter &writer, const ContestResult &result, const ContestTraceVector &trace) { JSON::ObjectWriter object(writer); object.WriteElement("score", JSON::WriteFixed, result.score); object.WriteElement("distance", JSON::WriteFixed, result.distance); object.WriteElement("duration", JSON::WriteUnsigned, (unsigned)result.time); object.WriteElement("speed", JSON::WriteFixed, result.GetSpeed()); object.WriteElement("turnpoints", WriteTrace, trace); }