Cod sursa(job #1426339)

Utilizator AlexNiuclaeNiculae Alexandru Vlad AlexNiuclae Data 29 aprilie 2015 15:03:58
Problema Cutii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <cstdio>
#include <algorithm>
#include <vector>

#define boxx pair < int , pair < int , int > >
#define X first
#define Y second.first
#define Z second.second

using namespace std;

const int Nmax = 3510;

int n , T , i , crt , sol;

boxx box[Nmax];

vector < boxx > q;
vector < boxx > :: iterator it;

int main()
{
    freopen("cutii.in","r",stdin);
    freopen("cutii.out","w",stdout);

    for (scanf("%d %d", &n, &T); T; --T)
    {
        for (i = 1; i <= n; ++i)
            scanf("%d %d %d", &box[i].X , &box[i].Y , &box[i].Z);

        sort(box + 1 , box + n + 1);

        for (sol = 0 , i = 1; i <= n; ++i)
        {
            bool ok = q.empty();

            for (it = q.begin(); it != q.end(); ++it)
             if (box[i].X > it -> X && box[i].Y > it -> Y && box[i].Z > it -> Z)
                q.erase(it) , it-- , ok = true;

            q.push_back(box[i]); if (ok) sol++;
        }

        printf("%d\n", sol);

        q.clear();
    }

    return 0;
}