Rezultati

Up. imeNalogaJezikRezultatČas oddaje
Aquasonic-2018 Zaletavanje C++ 100/100OK 19. apr '18 @ 19:30

Test Točke Porabljen spomin Porabljen čas Status
#1 14/14 3,195 MiB 0,000 s OK
#2 14/14 3,211 MiB 0,000 s OK
#3 14/14 3,199 MiB 0,004 s OK
#4 14/14 3,211 MiB 0,000 s OK
#5 14/14 3,211 MiB 0,000 s OK
#6 15/15 3,199 MiB 0,000 s OK
#7 15/15 3,219 MiB 0,059 s OK

Ocenjevani program (main.cpp):
#include <bits/stdc++.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back

#define left(x) ((x) << 1)
#define right(x) ((x) << 1 | 1)
#define mid(x, y) ((x) + (y) >> 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, bool> piib;

const int maxn = 1 * 1e2 + 17;

int N;
int ilen, jlen;
vector<piib> koli;
/// TRUE == UP

int where[maxn][maxn];

int collision()
{
    int v = 1e9 + 17;
    memset(where, 0, sizeof(where));

    for (int i = 0; i < koli.size(); i++) {
        for (int j = i + 1; j < koli.size(); j++) {
            piib ff = koli[i], ss = koli[j];

            if (ff.s == ss.s) continue;
            
            if (ff.s) swap(ff, ss);

            int ffi = ff.f.f, ffj = ff.f.s;
            int ssi = ss.f.f, ssj = ss.f.s;

///            printf("%d %d %d %d\n", ffi, ffj, ssi, ssj);

            if (ffj >= ssj || ssi >= ffi) continue; /// dodaj >= ???? primer 1. i 6.
        

        /// printf("PASS %d %d\n", i, j);
            

            if (ffi - ssi == ssj - ffj) {
                v = min(v, ffi - ssi);
                where[i][j] = where[j][i] = ffi - ssi;
            /// printf("COLLISION %d %d PO %d\n", i, j, ffi - ssi);
            }
        }
    }

    return v;
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> N >> jlen >> ilen;

    for (int i = 0; i < N; i++) {
        char t; int cj, ci;
        cin >> t >> cj >> ci;
        koli.pb(mp(mp(ci, cj), t == 'G'));
    }

    while (true)
    {
        int r = collision();

        if (r == 1e9 + 17) break;

        bool done[maxn];
        memset(done, 0, sizeof(done));

        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (where[i][j] == r) {
                    koli[i].s ^= true;
                    koli[j].s ^= true;
                    assert(!done[i]);
                    assert(!done[j]);
                    done[i] = true;
                    done[j] = true;
                }
            }
        }

        for (int i = 0; i < N; i++) {
            if (koli[i].s ^ done[i]) { /// ODI GORE
      ///      cout << "IDX " << i << endl;
///                int ci = koli[i].f.f;
///                ci = min(ci + r, jlen);
                koli[i].f.f = min(koli[i].f.f + r, ilen);
            } else {
         ///   int cj = koli[i].f.s;
            /// cj = min(cj + r, ilen);
                koli[i].f.s = min(koli[i].f.s + r, jlen);
            }
        }
/**
        for (int i = 0; i < N; i++) {
            cout << i << ": ";
            cout << koli[i].f.f << " " << koli[i].f.s << " " << koli[i].s << endl;
        }
**/
    }

    for (int i = 0; i < N; i++)
        if (koli[i].s) printf("%d %d\n", koli[i].f.s, ilen);
        else           printf("%d %d\n", jlen, koli[i].f.f);

        /**
            cout << ilen << " " << koli[i].f.s << endl;
        else
            cout << koli[i].f.f << " " << jlen << endl;
        **/ 


    return 0;
}