Pagini recente » Cod sursa (job #2773649) | Cod sursa (job #3165041) | Cod sursa (job #2805306) | Cod sursa (job #2707204) | Cod sursa (job #246486)
Cod sursa(job #246486)
// cutii.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <stdlib.h>
long long e[3504];
int f[3500];
bool g[3504];
int comparare(const void * a,const void * b)
{
return(*(long long*)a - *(long long*)b);
}
int main()
{
int n,t,i,j,l,valmax=0,k;
int a,c,d=0,p=1,numar=1,s;
long long b;
FILE *f1,*f2;
f1=fopen("cutii.in","r");
f2=fopen("cutii.out","w");
fscanf(f1,"%d %d",&n,&t);
for(i=1;i<=n;i++)
f[i]=1;
for(i=1;i<=t;i++)
{
for(j=1;j<=n;j++)
{
fscanf(f1,"%d %d %d",&a,&s,&c);
a=a*100000000+s*10000+c;
e[j]=a;
}
qsort(e,n+1,sizeof(long long),comparare);
for(j=1;j<=n;j++)
{
if(g[j])
continue;
numar=1;
p=1;
for(k=j+p;k<=n;k++)
{
b=e[j];
if(g[k])
continue;
for(l=k;l<=n;l++)
if(e[j]%100000000<e[l]%100000000 && e[j]%10000<e[l]%10000)
{
numar++;
e[j]=e[l];
g[l]=true;
}
p++;
if(numar>f[j])
f[j]=numar;
numar=1;
e[j]=b;
}
}
for(j=1;j<=n;j++)
{
if(f[j]>d)
d=f[j];
e[j]=0;
f[j]=1;
g[j]=false;
}
fprintf(f2,"%d\n",d);
d=0;
}
fclose(f1);
fclose(f2);
return 0;
}