11518 - Dominos 2

All about problems in Volume 115. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11518 - Dominos 2

Post by brianfry713 » Sat May 19, 2012 12:23 am

Input:

Code: Select all

1
3 2 2
1 2
2 3
2
2
AC output:

Code: Select all

2
Check input and AC output for thousands of problems on uDebug!

mathgirl
New poster
Posts: 36
Joined: Tue Apr 24, 2012 6:20 pm

Re: 11518 - Dominos 2

Post by mathgirl » Fri May 25, 2012 9:34 pm

Any tricky input for this problem ? I m getting WA.

Code: Select all

Nevermind, found my mistake. Got AC.

Labib
New poster
Posts: 12
Joined: Tue Mar 05, 2013 4:49 pm

Re: 11518 - Dominos 2

Post by Labib » Tue Mar 05, 2013 5:01 pm

please help me find the bug people
getting WA, but I dont know why? :-/

Code: Select all

AC
Last edited by Labib on Wed Mar 06, 2013 6:53 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11518 - Dominos 2

Post by brianfry713 » Tue Mar 05, 2013 10:53 pm

Input:

Code: Select all

1
5 4 1
1 2
1 3
1 4
1 5
1
AC output: 5
Check input and AC output for thousands of problems on uDebug!

Labib
New poster
Posts: 12
Joined: Tue Mar 05, 2013 4:49 pm

Re: 11518 - Dominos 2

Post by Labib » Wed Mar 06, 2013 6:53 pm

thanks brainfry :)

army007
New poster
Posts: 6
Joined: Tue Feb 19, 2013 10:34 pm
Location: Dhaka, Bangladesh

Re: 11518 - Dominos 2

Post by army007 » Wed Jul 03, 2013 12:54 am

I am getting WA, :( I am not sure why.

Here is my code:

Code: Select all

// removed after AC
Thanks in advance. :)
Last edited by army007 on Wed Jul 03, 2013 3:04 am, edited 1 time in total.
Human knowledge belongs to the world.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11518 - Dominos 2

Post by brianfry713 » Wed Jul 03, 2013 2:49 am

Input:

Code: Select all

1
3 2 3
1 2
2 3
3
2
1
Output should be 3
Check input and AC output for thousands of problems on uDebug!

army007
New poster
Posts: 6
Joined: Tue Feb 19, 2013 10:34 pm
Location: Dhaka, Bangladesh

Re: 11518 - Dominos 2

Post by army007 » Wed Jul 03, 2013 3:04 am

Thanks brianfry713.
Human knowledge belongs to the world.

hasancse
New poster
Posts: 1
Joined: Sun Apr 08, 2012 1:04 pm

Re: 11518 - Dominos 2

Post by hasancse » Tue May 27, 2014 12:18 pm

Getting WA. Please help...

Code: Select all

#include<stdio.h>
#define MAX 10002
bool g[MAX][MAX],n,m,l;
int countN;
bool mark[MAX];
void dfs(int start)
{
    if(mark[start]) return;
    mark[start] = true;
    for(int i=1;i<=n;i++)
        if(g[start][i])
        {
            g[start][i] = false;
            dfs(i);
        }
}
int main()
{
    //freopen("11518_inp.txt","r",stdin);
    int cs;
    scanf("%d",&cs);
    for(int csn=1;csn<=cs;csn++)
    {
        scanf("%d %d %d",&n,&m,&l);
        countN=0;
        for(int i=1;i<=n;mark[i]=false,i++)for(int j=1;j<=n;g[i][j]=false,j++);
        for(int i=1,v1,v2;i<=m;g[v1][v2]=true,i++)
            scanf("%d %d",&v1,&v2);
        for(int num=1,start;num<=l;num++)
            {
                scanf("%d",&start);
                dfs(start);
            }
        for(int i=1;i<=n;i++)
            if(mark[i])
                countN++;
        printf("%d\n",countN);
    }
    return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11518 - Dominos 2

Post by brianfry713 » Thu Jun 12, 2014 12:07 am

n, m, and l should be ints
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 115 (11500-11599)”