コード例 #1
0
ファイル: TestCase.cs プロジェクト: UIILabsDev/CodeJam
        public object Solve()
        {
            var dependencies = new DependencyMatrix(cars);
            var lanes = new LaneList(cars);

            var initialListIsOk = lanes.TryUpdate(dependencies);
            Debug.Assert(initialListIsOk);

            foreach (var e in Events.Enumerate(cars))
            {
                Debug.Assert(e.Time >= 0);

                if (e.Type == EventType.StartOverlapping)
                {
                    if (!dependencies.TryPutCarsOnOppositeLanes(e.Car1, e.Car2))
                        return e.Time;
                }

                if (e.Type == EventType.StopOverlapping)
                {
                    dependencies.RemoveCarsOnOppositeLanes(e.Car1, e.Car2);
                }

                if (!lanes.TryUpdate(dependencies))
                    return e.Time;
            }

            return "Possible";
        }
コード例 #2
0
ファイル: TestCase.cs プロジェクト: yash1998/CodeJam
        public object Solve()
        {
            var dependencies = new DependencyMatrix(cars);
            var lanes        = new LaneList(cars);

            var initialListIsOk = lanes.TryUpdate(dependencies);

            Debug.Assert(initialListIsOk);

            foreach (var e in Events.Enumerate(cars))
            {
                Debug.Assert(e.Time >= 0);

                if (e.Type == EventType.StartOverlapping)
                {
                    if (!dependencies.TryPutCarsOnOppositeLanes(e.Car1, e.Car2))
                    {
                        return(e.Time);
                    }
                }

                if (e.Type == EventType.StopOverlapping)
                {
                    dependencies.RemoveCarsOnOppositeLanes(e.Car1, e.Car2);
                }

                if (!lanes.TryUpdate(dependencies))
                {
                    return(e.Time);
                }
            }

            return("Possible");
        }