Pagini recente » Cod sursa (job #2137478) | Cod sursa (job #1165693) | Cod sursa (job #2155338) | Cod sursa (job #2486254) | Cod sursa (job #73685)
Cod sursa(job #73685)
#include<cstdio>
#include<cstdlib>
int nr;
struct cutie{
int a, b, c;
};
cutie v[3505];
int comp(const void*x, const void*y){
cutie xx=*(cutie*)x, yy=*(cutie*)y;
if (xx.a<yy.a) return -1;
if (xx.a>yy.a) return 1;
return 0;
}
struct ches{
int q, w;
};
ches s[3505];
void caut(int x, int y){
int li = 1, ls = nr, p;
while (li<=ls){
p = (li+ls)/2;
if (s[p].q==x && s[p].w==y)
return;
if (y > s[p].w || x> s[p].q)
li = p+1;
else
if (s[p-1].q < x && s[p-1].w < y){
s[p].q = x;
s[p].w = y;
return ;
}
else
ls = p-1;
}
if (x>s[nr].q && y>s[nr].w){
s[++nr].q = x;
s[nr].w = y;
}
}
int main()
{
freopen("cutii.in","r",stdin);
freopen("cutii.out","w",stdout);
int n, t, nrt, i;
scanf("%d%d", &n, &t);
for (nrt=1; nrt<=t; nrt++){
for (i=1; i<=n; i++)
scanf("%d%d%d", &v[i].a, &v[i].b, &v[i].c);
qsort(v, n+1, sizeof(v[0]), comp);
for (i=1; i<=nr; i++){
s[i].q = 0;
s[i].w = 0;
}
nr = 1;
s[nr].q = v[1].b;
s[nr].w = v[1].c;
for (i=2; i<=n; i++)
caut(v[i].b, v[i].c);
printf("%d\n", nr);
}
fclose(stdin);
fclose(stdout);
return 0;
}