ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1489. Points on a Parallelepiped

wa 10
Posted by Michael Glushkov 11 Nov 2019 21:39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1489
{
    class Point
    {
        public double x;
        public double y;
        public double z;
        static void Main(string[] args)
        {
            int A, B, C;
            string S = Console.ReadLine();
            string[] SS = S.Split();
            A = Convert.ToInt32(SS[0]);
            B = Convert.ToInt32(SS[1]);
            C = Convert.ToInt32(SS[2]);

            double x1, y1, x2, y2;
            double[] mas = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            x1 = Convert.ToDouble(mas[0]);
            y1 = Convert.ToDouble(mas[1]);
            double[] mas2 = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            x2 = Convert.ToDouble(mas2[0]);
            y2 = Convert.ToDouble(mas2[1]);

            Point a = new Point();

                // A - x B - y C - z
                // x
                if (x1 <= C) a.x = 0;
                else if (x1 <= C + A) a.x = x1 - C;
                else a.x = A;

                // y

                if (y1 <= B) a.y = B - y1;
                else if (y1 <= B + C) a.y = 0;
                else if (y1 <= 2 * B + C) a.y = y1 - B - C;
                else a.y = B;

                // z
                if (y1 <= B) a.z = 0;
                else if (y1 <= B + C && x1 <= C + A && x1 >= C) a.z = y1 - B;
                else if (x1 <= C && y1 <= 2 * B + C) a.z = x1;
                else if (x1 >= C + A && y1 <= 2 * B + C) a.z = A + C + C - x1;
                else if (y1 >= B + C + B) a.z = 2 * (B + C) - y1;
                else a.z = C;

            Point b = new Point();

                // x
                if (x2 <= C) b.x = 0;
                else if (x2 <= C + A) b.x = x2 - C;
                else b.x = A;

                // y
                if (y2 <= B) b.y = B - y2;
                else if (y2 <= B + C) b.y = 0;
                else if (y2 <= 2 * B + C) b.y = y2 - B - C;
                else b.y = B;

                // z
                if (y2 <= B) b.z = 0;
                else if (y2 <= B + C && x2 <= C + A && x2 >= C) b.z = y2 - B;
                else if (x2 <= C && y2 <= 2 * B + C) b.z = x2;
                else if (x2 >= C + A && y2 <= 2 * B + C) b.z = A + C + C - x2;
                else if (y2 >= B + C + B) b.z = 2 * (B + C) - y2;
                else b.x = C;

            double difx = (a.x - b.x);
            double dify = (a.y - b.y);
            double difz = (a.z - b.z);
            //if (difx * difx + dify * dify + difz * difz > 0)
                Console.WriteLine((Math.Sqrt(difx * difx + dify * dify + difz * difz)));
            //else Console.Write(0);
        }
    }
}