Rezultati

Up. imeNalogaJezikRezultatČas oddaje
3-8byte-2018 Zaletavanje C# 0/100Prekoračen čas (TLE) 19. apr '18 @ 17:38

Test Točke Porabljen spomin Porabljen čas Status
#1 14/14 20,473 MiB 0,000 s OK
#2 14/14 16,484 MiB 0,000 s OK
#3 14/14 20,250 MiB 0,000 s OK
#4 14/14 20,473 MiB 0,000 s OK
#5 14/14 12,594 MiB 0,000 s OK
#6 0/15 19,766 MiB 5,806 s Prekoračen čas
#7 0/15 17,688 MiB 5,821 s Prekoračen čas

Ocenjevani program (Program(1).cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zaletavanje
{
	public struct Car
	{
		public bool direction;
		public int x;
		public int y;
		public int steps;

		public Car(string line)
		{
			steps = 0;
			string[] split = line.Split(' ');

			direction = (split[0] == "G");
			x = int.Parse(split[1]);
			y = int.Parse(split[2]);
		}

		public void Step()
		{
			if (direction)
			{
				y++;
			}
			else
				x++;
		}
	}


	class Program
	{
		public static void Steps(Car[] cars)
		{
			for (int i = 0; i < cars.Length; i++)
			{
				cars[i].Step();
			}
		}
		public static void Collisions(int steps, Car[] cars)
		{
			for (int i = 0; i < cars.Length; i++)
			{
				for (int j = 0; j < cars.Length; j++)
				{
					if (i < j)
					{
						if (cars[i].x == cars[j].x && cars[i].y == cars[j].y)
						{
							//cars[i].direction = !(cars[j].direction = !cars[j].direction);
							cars[i].direction = cars[j].direction;
							cars[j].direction = !cars[i].direction;
						}
					}
				}
			}
		}
		static void Main(string[] args)
		{
			int steps = 0;
			string line = Console.ReadLine();
			string[] split = line.Split(' ');
			int N = int.Parse(split[0]);
			int W = int.Parse(split[1]);
			int H = int.Parse(split[2]);

			Car[] cars = new Car[N];

			for (int i = 0; i < N; i++)
			{
				line = Console.ReadLine();
				cars[i] = new Car(line);
			}

			for (int i = 0; i < Math.Max(W, H); i++)
			{
				Collisions(i, cars);
				Steps(cars);
			}

			for (int i = 0; i < cars.Length; i++)
			{
				if (cars[i].x >= W)
				{
					cars[i].x = W;
				}
				if (cars[i].y >= H)
				{
					cars[i].y = H;
				}
			}

			for (int i = 0; i < cars.Length; i++)
			{
				Console.WriteLine($"{cars[i].x} {cars[i].y}");
			}
			Console.ReadLine();
		}
	}
}