Cod sursa(job #2152587)

Utilizator MihalachiRazvanMihalachi Razvan MihalachiRazvan Data 5 martie 2018 17:54:43
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#define dim 3502
using namespace std;
ifstream fin("cutii.in");
ofstream fout("cutii.out");
struct cutie
{
    int x,y,z;
}c[dim];
bool cmp(cutie a, cutie b)
{
        if(a.x==b.x)
        if(a.y==b.y)
            return a.z<b.z;
        else
            return a.y<b.y;
    return a.x<b.x;
    }
int N,T;
int main()
{
    fin>>N>>T;
    int i,j;
    for(i=1;i<=T;i++)
    {
        for(j=1;j<=N;j++)
        fin>>c[j].x>>c[j].y>>c[j].z;
        sort(c+1,c+N+1,cmp);
        int k,maxc=0,aux=0;
        c[0].x=c[0].y=c[0].z=0;
        for(int i=1;i<=N;i++)
            if(c[aux].x<c[i].x&&c[aux].y<c[i].y&&c[aux].z<c[i].z)
            {
                aux=i;
                maxc++;
            }
          fout<<maxc<<"\n";
    }
    return 0;
}