Rezultati

Up. imeNalogaJezikRezultatČas oddaje
finalsolution-2018 Zaletavanje C 100/100OK 19. apr '18 @ 18:03

Test Točke Porabljen spomin Porabljen čas Status
#1 14/14 1,465 MiB 0,000 s OK
#2 14/14 1,465 MiB 0,005 s OK
#3 14/14 1,488 MiB 0,000 s OK
#4 14/14 1,496 MiB 0,000 s OK
#5 14/14 1,465 MiB 0,005 s OK
#6 15/15 1,492 MiB 0,000 s OK
#7 15/15 1,477 MiB 0,000 s OK

Ocenjevani program (zaletavanje.c):
#include <stdio.h>
#include <stdlib.h>

struct avto {
    int x;
    int y;
    int d;
};

struct trk {
    int t;
    short a;
    short b;
};

static struct avto A[100];
static struct trk T[10000];
static int F[100];
static int R[100];

static int compar(const struct trk *a, const struct trk *b) {
    return a->t - b->t;
}

int main() {
    int i = 0, j = 0, n = 0, w = 0, h = 0, t = 0;
    scanf("%d %d %d", &n, &w, &h);
    for (; i < n; i++) {
        char c = 0;
        scanf(" %c %d %d", &c, &A[i].x, &A[i].y);
        A[i].d = (c == 'G' ? 1 : 0);
        F[i] = i;
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (i == j) continue;
            if (A[i].d == 0 && A[j].d == 1 && A[i].x < A[j].x && A[i].y > A[j].y) {
                if (A[j].x - A[i].x == A[i].y - A[j].y) {
                    T[t].t = A[j].x - A[i].x;
                    T[t].a = i;
                    T[t].b = j;
                    t++;
                }
            }
        }
    }
    qsort(T, t, sizeof(T[0]), (int (*)(const void *, const void *))compar);
    for (i = 0; i < t; i++) {
        int v = F[T[i].a];
        F[T[i].a] = F[T[i].b];
        F[T[i].b] = v;
    }
    for (i = 0; i < n; i++) R[F[i]] = i;
    for (i = 0; i < n; i++) {
        int v = R[i];
        if (A[v].d) printf("%d %d\n", A[v].x, h);
        else printf("%d %d\n", w, A[v].y);
    }
    return 0;
}