Rezultati

Up. imeNalogaJezikRezultatČas oddaje
tabs-2018 Zaletavanje C++ 0/100Prekoračen čas (TLE) 19. apr '18 @ 19:03

Test Točke Porabljen spomin Porabljen čas Status
#1 14/14 3,035 MiB 0,000 s OK
#2 14/14 3,039 MiB 0,004 s OK
#3 0/14 3,031 MiB 0,000 s Napačen odgovor
Tvoj izhod:
​7 5
0 7
0 7
5 7
7 5
8 2
8 6
1 7
7 7
8 4
Pravilen izhod:
​7 5
0 7
0 7
5 7
7 5
7 2
7 6
1 7
7 7
7 4
#4 14/14 3,188 MiB 0,001 s OK
#5 14/14 3,039 MiB 0,007 s OK
#6 0/15 2,938 MiB 6,082 s Prekoračen čas
#7 0/15 2,938 MiB 6,076 s Prekoračen čas

Ocenjevani program (main.cpp):
#include <algorithm>
#include <array>
#include <complex>
#include <cmath>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int N, W, H;

struct avto
{
	int x, y, id, endX, endY;
	char smer;
	bool isDead;
	bool operator<(const avto& tmp) const
	{
		if(x < tmp.x || (x == tmp.x && y <= tmp.y))
			return true;
		return false;
	}
	bool operator>(const avto& tmp)const
	{
		return (id < tmp.id);
	}

};
set <avto*> q;
set <avto*> ::iterator it;

void removeOld(int x)
{
	for(it = q.begin(); it != q.end(); ++it)
	{
		struct avto* pom = *it;
		if(pom->x <= x)
			q.erase(pom);
	}
}

int main()
{
	cin>>N>>W>>H;
	vector<struct avto> avti;
	for(int i=0;i<N;i++)
	{
		struct avto pom;
		cin>>pom.smer>>pom.x>>pom.y;	
		pom.id = i;	
		pom.isDead = false;
		avti.push_back(pom);	
	}
	
	bool anyAlive = true;
	int h = 0;
	while(anyAlive)	
	{
		
		q.erase(q.begin(), q.end());
		sort(avti.begin(), avti.end());
		anyAlive = false;
		int currX = avti[0].x;
		for(int i=0; i<N; i++)
		{
			anyAlive = false;
			while(i < N)
			{	
				currX = avti[i].x;
				if(avti[i].isDead) 
				{ i++; continue; }			
				if(avti[i].smer == 'D')
					avti[i].x++;
				else
					avti[i].y++;

				for(it = q.begin(); it != q.end(); ++it)
				{
					if((*it)->x == avti[i].x && (*it)->y == avti[i].y)
					{
						if(avti[i].smer == 'D')
						{
							avti[i].smer = 'G';
							(*it)->smer = 'D';
						}
						else
						{
							avti[i].smer = 'D';
							(*it)->smer = 'G';
						}
					}
				}
				q.insert(&avti[i]);
				i++;
				

			}

			removeOld(currX-1);
			
		}
		anyAlive = false;
		for(int i=0; i<N; i++)
		{
			if(!avti[i].isDead)
			{
				if(avti[i].x >= W && avti[i].smer == 'D')
				{
					avti[i].isDead = true;
					avti[i].endX = avti[i].x;
					avti[i].endY = avti[i].y;
				}
				else if (avti[i].y >= H && avti[i].smer == 'G')
				{
					avti[i].isDead = true;
					avti[i].endX = avti[i].x;
					avti[i].endY = avti[i].y;
				}
					
			}
			if(!avti[i].isDead) anyAlive = true;
		}
		if(!anyAlive) break;
		
	}
	

	
	sort(avti.begin(), avti.end(), greater<avto>());

	for(int i=0; i<N; i++)
		cout<<avti[i].endX<<" "<<avti[i].endY<<endl;
	

	return 0;
}