Submission #2326689


Source Code Expand

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    struct P
    {
        public double X, Y;

        public P(double x, double y)
        {
            X = x;
            Y = y;
        }
    }

    class Program
    {
        private P A, B, C;
        private double a, b, c;
        private void Scan()
        {
            var sc = new Scanner();
            A = new P(sc.NextInt(), sc.NextInt());
            B = new P(sc.NextInt(), sc.NextInt());
            C = new P(sc.NextInt(), sc.NextInt());
        }

        public void Solve()
        {
            Scan();
            a = Dist(B, C);
            b = Dist(C, A);
            c = Dist(A, B);
            double s = S(A, B, C);
            double r = s / (a + b + c) * 2;
            double min = 0;
            double max = r;
            double l = Math.Max(Math.Max(a, b), c);
            for (int i = 0; i < 10000; i++)
            {
                double mid = (min + max) / 2;
                if (mid * 2 < l * (1 - (mid / r)))
                {

                    min = mid;
                }
                else
                {
                    max = mid;
                }
            }
            Console.WriteLine(min);
        }

        private double S(P one, P two, P three)
        {
            return S(new P(two.X - one.X, two.Y - one.Y), new P(three.X - one.X, three.Y - one.Y));
        }

        private double S(P one, P two)
        {
            return Math.Abs(one.X * two.Y - one.Y * two.X) / 2;
        }

        private double Dist(P one, P two)
        {
            return Math.Sqrt((one.X - two.X) * (one.X - two.X) + (one.Y - two.Y) * (one.Y - two.Y));
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Submission Info

Submission Time
Task B - Inscribed Bicycle
User mban
Language C# (Mono 4.6.2.0)
Score 500
Code Size 3446 Byte
Status AC
Exec Time 21 ms
Memory 11220 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 21 ms 11092 KB
001.txt AC 21 ms 11092 KB
002.txt AC 21 ms 11092 KB
003.txt AC 21 ms 9044 KB
004.txt AC 21 ms 9044 KB
005.txt AC 21 ms 11092 KB
006.txt AC 21 ms 9044 KB
007.txt AC 21 ms 9044 KB
008.txt AC 21 ms 9044 KB
009.txt AC 21 ms 9044 KB
010.txt AC 21 ms 9044 KB
011.txt AC 21 ms 11092 KB
012.txt AC 21 ms 11092 KB
013.txt AC 21 ms 11220 KB
014.txt AC 21 ms 9044 KB
015.txt AC 21 ms 9044 KB
example0.txt AC 20 ms 9044 KB
example1.txt AC 21 ms 11092 KB