ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1128. Partition into Groups

Please help me.I've WA#3.If you can,please,give me some tests.Thank!!!!Here is my code:
Posted by Search 20 Aug 2008 02:54
#include<iostream.h>
int main()
{
    int n,i,j,k[7165],l,**a,b[7165],kol=0;
    cin>>n;
        a=new int *[n+1];
for(i=1;i<=n;i++)
a[i]=new int[n+1];
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
a[i][j]=0;
for(i=1;i<=n;i++)
{
    cin>>k[i];
    for(j=0;j<k[i];j++)
    {
        cin>>l;
        a[i][l]=1;
    }
}
for(i=1;i<=n;i++)
{
    if(k[i]>1)
    {
    b[kol++]=i;
        for(j=i+1;j<=n;j++)
            if(a[j][i]==1)
            {
                a[j][i]=0;
                k[j]--;
            }
    }
}

cout<<kol<<endl;
if(kol!=0){
for(i=0;i<kol;i++)
cout<<b[i]<<" ";}
return 0;
}
Thank in advance!!!!!!
Re: Please help me.I've WA#3.If you can,please,give me some tests.Thank!!!!Here is my code:
Posted by hedrok (ONPU) 2 Sep 2008 18:27
Try this:
4
1 3
2 3 4
3 1 2 4
2 2 3
Your output:
2
2 3
This answer is wrong.
"If the groups are of the same size then you are to describe the group that contains the child number one"
So possible answer is:
2
1 4