Cod sursa(job #2470241)

Utilizator mihailescu_eduardMihailescu Eduard-Florin mihailescu_eduard Data 8 octombrie 2019 21:44:14
Problema Cutii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.27 kb
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

ifstream fin("cutii.in");
ofstream fout("cutii.out");

static const int NMAX = 3505;
int ind[NMAX];
//int res[NMAX];
int x[NMAX], y[NMAX], z[NMAX];

bool cmp(const int &a, const int &b)
{
    if(x[a] == x[b])
    {
        if(y[a] == y[b])
            return z[a] < z[b];
        return y[a] < y[b];
    }
    return x[a] < x[b];
}

void constructSubstring()
{
    
}

/*
if(x[ind[i]] > x[res[sz]] && y[ind[i]] > y[res[sz]] && z[ind[i]] > z[res[sz]])
{
    res[++sz] = ind[i];
}
else
{
    int low = 1, high = sz, sol, mid;
    while(low <= high)
    {
        int mid = low + (high-low) / 2;
        if()
    }
}
*/

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, t;
    fin>> n >> t;

    while(t--)
    {
        for(int i =1 ; i<= n; ++i)
        {
            fin >> x[i] >> y[i] >> z[i];
            ind[i] = i;
        }
        sort(ind+1, ind+n+1,cmp);
        int sol = 0;
        int k = 1;
        for(int i= 2; i<=n; ++i)
        {
            if(x[ind[i]] > x[ind[k]] && y[ind[i]] > y[ind[k]] && z[ind[i]] > z[ind[k]])
            {
                sol++;
                k++;
            }
        }
        fout << sol+1 << '\n';
    }


    return 0;
}