Submission #3317656


Source Code Expand

object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val X, Y = Array.ofDim[Int](3)
    rep(3) { i =>
      X(i) = ni()
      Y(i) = ni()
    }

    val a = Array.ofDim[Double](3)
    def calcAngle(i: Int, j: Int, k: Int) = {
      abs(angle(X(j) - X(i), Y(j) - Y(i), X(k) - X(i), Y(k) - Y(i))) / 2
    }

    def calcR(i: Int, j: Int): Double = {
      import java.awt.geom.Point2D
      val L = Point2D.distance(X(i), Y(i), X(j), Y(j))
      val t1 = Math.tan(a(i))
      val t2 = Math.tan(a(j))
      L / (2 + 1 / t1 + 1 / t2)
    }

    a(0) = calcAngle(0, 1, 2)
    a(1) = calcAngle(1, 2, 0)
    a(2) = calcAngle(2, 0, 1)

//    a map (_ / Math.PI * 180) foreach System.err.println

    val r = Seq(calcR(0, 1), calcR(1, 2), calcR(0, 2))
    out.println(f"${r.max}%.12f")
  }

  /**
    * [-π, π]
    */
  def angle(x1: Int, y1: Int, x2: Int, y2: Int): Double = {
    val sin = -y1 * x2 + x1 * y2  // perp dot product
    val cos = x1 * x2 + y1 * y2   // dot product
    Math.atan2(sin, cos)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

Submission Info

Submission Time
Task B - Inscribed Bicycle
User yakamoto
Language Scala (2.11.7)
Score 500
Code Size 2888 Byte
Status AC
Exec Time 331 ms
Memory 27332 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 18
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 329 ms 25376 KB
001.txt AC 331 ms 27332 KB
002.txt AC 319 ms 25176 KB
003.txt AC 322 ms 25272 KB
004.txt AC 325 ms 23480 KB
005.txt AC 321 ms 25272 KB
006.txt AC 320 ms 25248 KB
007.txt AC 326 ms 25408 KB
008.txt AC 320 ms 25280 KB
009.txt AC 323 ms 25156 KB
010.txt AC 321 ms 25276 KB
011.txt AC 319 ms 25284 KB
012.txt AC 325 ms 25288 KB
013.txt AC 321 ms 25288 KB
014.txt AC 324 ms 25280 KB
015.txt AC 323 ms 25280 KB
example0.txt AC 322 ms 25156 KB
example1.txt AC 324 ms 27076 KB