Rezultati

Up. imeNalogaJezikRezultatČas oddaje
3-8byte-2018 Droni C++ 0/100Prekoračen čas (TLE) 10. maj '18 @ 18:01

Test Točke Porabljen spomin Porabljen čas Status
#1 0/5 3,000 MiB 0,004 s Napačen odgovor
Povratna informacija sodniškega sistema:
​The program made an invalid move.
#2 0/5 3,133 MiB 0,004 s Napačen odgovor
Povratna informacija sodniškega sistema:
​The program made an invalid move.
#3 5/5 3,000 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#4 5/5 3,133 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#5 5/5 3,133 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#6 5/5 3,000 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#7 5/5 3,133 MiB 0,003 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#8 0/5 3,133 MiB 0,004 s Napačen odgovor
Povratna informacija sodniškega sistema:
​The program made an invalid move.
#9 0/5 3,133 MiB 0,004 s Napačen odgovor
Povratna informacija sodniškega sistema:
​The program made an invalid move.
#10 5/5 3,000 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#11 0/5 2,996 MiB 0,004 s Napačen odgovor
Povratna informacija sodniškega sistema:
​The program made an invalid move.
#12 5/5 3,133 MiB 0,004 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#13 5/5 3,125 MiB 0,004 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#14 5/5 3,000 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#15 5/5 3,125 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#16 5/5 3,133 MiB 0,000 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#17 5/5 2,992 MiB 0,004 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#18 5/5 3,000 MiB 0,004 s OK
Povratna informacija sodniškega sistema:
​The output was correct.
#19 0/5 2,949 MiB 0,000 s Prekoračen čas
Povratna informacija sodniškega sistema:
​The program made an invalid move.
#20 5/5 3,129 MiB 0,004 s OK
Povratna informacija sodniškega sistema:
​The output was correct.

Ocenjevani program (main.cpp):
#include <vector>
#include <iostream>

using namespace std;

struct Point
{
	int x;
	int y;
	int z;

	Point(int x, int y, int z) :
		x(x),
		y(y),
		z(z)
	{

	}
	Point() : Point(0, 0, 0)
	{

	}

	Point NextDirection(Point& end)
	{
		if (x < end.x)
		{
			return Point(1, 0, 0);
		}
		else if (x > end.x)
		{
			return Point(-1, 0, 0);
		}
		
		if (y < end.y)
		{
			return Point(0, 1, 0);
		}
		else if (y > end.y)
		{
			return Point(0, -1, 0);
		}

		if (z < end.z)
		{
			return Point(0, 0, 1);
		}
		else if (z > end.z)
		{
			return Point(0, 0, -1);
		}

		return Point(0, 0, 0);
	}
};

ostream& operator<<(ostream& stream, Point& pt)
{
	stream << '(' << pt.x << ' ' << pt.y << ' ' << pt.z << ')';
	return stream;
}

istream& operator>>(istream& stream, Point& pt)
{
	stream >> pt.x >> pt.y >> pt.z;
	return stream;
}

bool operator==(Point& pt1, Point& pt2)
{
	return pt1.x == pt2.x && pt1.y == pt2.y && pt1.z == pt2.z;
}

bool operator!=(Point& pt1, Point& pt2)
{
	return !operator==(pt1, pt2);
}

Point operator+(Point& pt1, Point& pt2)
{
	return Point(pt1.x + pt2.x, pt1.y + pt2.y, pt1.z + pt2.z);
}
int main()
{
	Point start1;
	Point end1;
	Point start2;
	Point end2;

	cin >> start1 >> end1 >> start2 >> end2;

	while (true)
	{
		cout << start1 << ' ' << start2 << endl;

		if (start1 == end1 && start2 == end2)
			break;

		Point d1 = start1.NextDirection(end1);
		Point d2 = start2.NextDirection(end2);
		Point n1 = start1 + d1;
		Point n2 = start2 + d2;

		if (n1 == start2 && n2 == start1)
		{
			if (abs(d1.x) == abs(d2.x) && d1.x != 0)
			{
				d1.x = 0;
				d1.y = 1;
				d2.x = 0;
				d2.y = -1;
			}
			else if (abs(d1.y) == abs(d2.y) && d1.y != 0)
			{
				d1.y = 0;
				d1.z = 1;
				d2.y = 0;
				d2.z = -1;
			}
			else if (abs(d1.z) == abs(d2.z) && d1.z != 0)
			{
				d1.z = 0;
				d1.x = 1;
				d2.z = 0;
				d2.x = -1;
			}
		}

		n1 = start1 + d1;
		n2 = start2 + d2;

		start1 = n1;
		start2 = n2;

	}
	return 0;
}