Rezultati

Up. imeNalogaJezikRezultatČas oddaje
functor2018 Zaletavanje C++ Se ne prevede 19. apr '18 @ 20:15

Izpis prevajalnika:
source.c++: In function ‘int main()’:
source.c++:83:22: error: ‘print’ was not declared in this scope
     print("%d\n", *it);
                      ^
source.c++:55:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d\n", &N, &W, &H);
                                  ^
source.c++:63:72: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%c %d %d\n", &arr[i].avto.s, &arr[i].avto.x, &arr[i].avto.y);
                                                                        ^

Ocenjevani program (zaletavanje.cpp):
#include <stdio.h>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

struct Avto
{
	int x, y;
	char s;
	long d;
};

struct Avtoarr
{
  int id;
  Avto avto;
  unsigned long long e = -1;
  long last = -1;
};

struct ltstr
{
	bool operator()(const Avtoarr a1, const Avtoarr a2) const
	{
	  return a1.e < a2.e;
	}
};

void swap_avto(Avtoarr arr[], Avtoarr* link[], int i, int j) {
	Avtoarr tmp;
	tmp.avto = arr[i].avto;
	tmp.e = arr[i].e;
	tmp.id = arr[i].id;
	arr[i].avto = arr[j].avto;
	arr[i].e = arr[j].e;
	arr[i].id = arr[j].id;
	arr[j].avto = tmp.avto;
	arr[j].e = tmp.e;
	arr[j].id = tmp.id;
	tmp.avto.s = arr[i].avto.s;
	arr[i].avto.s = arr[j].avto.s;
	arr[j].avto.s = tmp.avto.s;
	
	Avtoarr *t;
	t = link[i];
	link[i]=link[j];
	link[j] = t;
}

int main()
{
  int N, W, H;
  scanf("%d %d %d\n", &N, &W, &H);
  Avtoarr *link[100002];
  Avtoarr  arr [100002];
  map<long, vector<int> > diagonale;
  for (int i = 0; i < N; ++i)
  {
  	link[i] = &arr[i];
  	arr[i].id = i + 1;
    scanf("%c %d %d\n", &arr[i].avto.s, &arr[i].avto.x, &arr[i].avto.y);
    arr[i].e = arr[i].avto.x * arr[i].avto.x + arr[i].avto.y * arr[i].avto.y;
    long d = arr[i].avto.x + arr[i].avto.y;
    if (diagonale.find(d) == diagonale.end())
    {
      vector<int> v;
      diagonale.insert(pair<long, vector<int> >(arr[i].avto.x+arr[i].avto.y, v));
    }
    auto e = diagonale.find(d);
    e->second.push_back(i);
  }
  sort(arr, arr+N, ltstr());
  /*auto e = diagonale.find(4);
  for (auto it = e->second.begin(); it != e->second.end(); ++it)
    printf("%i\n", *it);
  */
  for (int i = 0; i < N; ++i) {
  	auto e = diagonale.find(arr[i].avto.d);
	Avtoarr *a1 = link[i];
  	for (auto it = e->second.begin(); it != e->second.end(); ++it) {
  		print("%d\n", *it);
		Avtoarr *a2 = link[*it];
		if (a1->avto.s != a2->avto.s) {
			if (a1->avto.s == 'G'){
				if (a1->avto.y < a2->avto.y)
					if (a1->avto.x - a2->avto.x == a2->avto.y - a1->avto.y)
						swap_avto(arr, link, i, *it);
			}
			else {
				if (a2->avto.y < a1->avto.y)
					if (a2->avto.x - a1->avto.x == a1->avto.y - a2->avto.y)
						swap_avto(arr, link, i, *it);
			}
		}
  	}
  }
  
  for (int i = 0; i < N; ++i)
  {
  	if (link[i]->avto.s == 'G')
	  	printf("%d %d\n", link[i]->avto.x, H);
	else
		printf("%d %d\n", W, link[i]->avto.y);
  }
  
  return 0;
}