Pagini recente » Cod sursa (job #2338110) | Cod sursa (job #2284256) | Cod sursa (job #1625951) | Cod sursa (job #1781038) | Cod sursa (job #75826)
Cod sursa(job #75826)
# include <stdio.h>
const long int MAXN=10000;
const long int NRBITI=15;
long int a[MAXN+1][MAXN/NRBITI+2];
long int n,m;
void insert(long int aa, long int bb)
{
long int x,y;
x=aa;
if (bb%NRBITI) y=bb/NRBITI+1;
else y=bb/NRBITI;
bb%=NRBITI;
if (!bb) bb=NRBITI;
a[x][y]|=((long int)1<<(bb-1));
}
void citire()
{
FILE *f=fopen("count.in","r");
fscanf(f,"%ld%ld",&n,&m);
long int i,aa,bb;
for (i=1;i<=m;i++)
{
fscanf(f,"%ld%ld",&aa,&bb);
insert(aa,bb);
insert(bb,aa);
}
fclose(f);
}
int retrieve(long int i, long int j)
{
long int x,y;
x=i;
if (j%NRBITI) y=j/NRBITI+1;
else y=j/NRBITI;
j%=NRBITI;
if (!j) j=NRBITI;
if (a[x][y]&((long int)1<<(j-1))) return 1;
return 0;
}
void scrie(long int max, long int count)
{
FILE *g=fopen("count.out","w");
fprintf(g,"%ld %ld\n",max,count);
fcloseall();
}
void gen()
{
long int i,j,k,l,max,count;
max=2;count=m;
for (i=1;i<=n;i++)
for (j=i+1;j<=n;j++)
if (retrieve(i,j))
for (k=j+1;k<=n;k++)
if (retrieve(i,k)&&retrieve(j,k))
{
if (max<3) {max=3;count=0;}
if (max==3) count++;
for (l=k+1;l<=n;l++)
if (retrieve(i,l)&&retrieve(j,l)&&retrieve(k,l))
{
if (max<4) {max=4;count=0;}
if (max==4) count++;
}
}
scrie(max,count);
}
int main()
{
citire();
gen();
return 0;
}