11686 - Pick up sticks

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

Moderator: Board moderators

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11686 How can

Post by saiful_sust » Wed Oct 07, 2009 6:04 pm

Some PLZ help me .........
I am try to solve this problem and got WA :oops: :oops:

Here is my code....

Code: Select all

Cut ...........
Last edited by saiful_sust on Sun Oct 11, 2009 10:00 am, edited 1 time in total.

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: 11686 How can

Post by arifcsecu » Wed Oct 07, 2009 6:29 pm

This is topological sort
So try to use vector instead of 2D array

Use dfs algorithm and with in dfs
you have to check back edge and
use a stack to contain the fast blacken vertices

and also take input using scanf
and output using printf


i hopes ....
Try to catch fish rather than asking for some fishes.

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: 11686 How can

Post by arifcsecu » Wed Oct 07, 2009 6:31 pm

Code remove
Last edited by arifcsecu on Mon Oct 12, 2009 6:06 am, edited 1 time in total.
Try to catch fish rather than asking for some fishes.

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11686 How can

Post by saiful_sust » Sun Oct 11, 2009 10:03 am

Thanks for ur reply ...
one thing u don't need to post my code in ur comment.

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11686 How can

Post by saiful_sust » Wed Oct 14, 2009 8:56 am

I M try to solve this problem
BUT got WA many time ...

Now i use topological sort using DFS and vector

Some one PLZ help me .......
HERE is my code

Code: Select all

Cut for edit............................
Last edited by saiful_sust on Thu Oct 15, 2009 6:32 pm, edited 1 time in total.

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: 11686 How can

Post by arifcsecu » Wed Oct 14, 2009 7:29 pm

You make a simple error

n is 10^6

so you vector should be like

vector <long int> g[1000001];

but you declares as

vector <int> adjlist[100001]

Hope it helps
Try to catch fish rather than asking for some fishes.

Igor9669
Learning poster
Posts: 85
Joined: Sun Jun 08, 2008 12:58 pm

Re: 11686 How can

Post by Igor9669 » Thu Oct 15, 2009 7:44 am

arifcsecu wrote:You make a simple error

n is 10^6

so you vector should be like

vector <long int> g[1000001];
Hope it helps
May be g(1000001) not g[1000001] ????

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11686 How can

Post by saiful_sust » Thu Oct 15, 2009 11:58 am

Thanks arifcsecu and Igor9669 4 ur reply

But i got WA again ...I feel boring with this problem...
Some one PLz help me. :oops: :oops:

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 11686 How can

Post by helloneo » Thu Oct 15, 2009 6:18 pm

What I found is k is not initialized at the very first time.. But, I don't know anything else
Your code is quite similar to mine.. :-)

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11686 How can

Post by saiful_sust » Thu Oct 15, 2009 6:31 pm

Thanks helloneo...for ur post

But still i got WA...
Here is my code.................. :oops: :oops:

Code: Select all

CUT 4 edit..... 
Last edited by saiful_sust on Sat Oct 17, 2009 1:19 pm, edited 1 time in total.

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: 11686 How can

Post by arifcsecu » Thu Oct 15, 2009 6:58 pm

code removed
Last edited by arifcsecu on Mon Oct 19, 2009 11:00 am, edited 1 time in total.
Try to catch fish rather than asking for some fishes.

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: 11686 - Pick up sticks - possible in Java?

Post by arifcsecu » Thu Oct 15, 2009 7:25 pm

why not
it is possible in java
This is topological sorting

use dfs
Just use an array for color[]
and use a stack for the topological order of vertices
and use vector for reading graph input instead of 2D array

Hope it helps
Try to catch fish rather than asking for some fishes.

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11686 How can

Post by saiful_sust » Sat Oct 17, 2009 1:19 pm

Thanks u arifcsecu....
But i don;t got ACCC...

Here is my new code....

Code: Select all

CUT 4 edit........... :oops:  :oops: 
Last edited by saiful_sust on Sun Oct 18, 2009 11:45 am, edited 1 time in total.

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: 11686 How can

Post by arifcsecu » Sat Oct 17, 2009 3:18 pm

removed
Last edited by arifcsecu on Mon Oct 19, 2009 10:59 am, edited 1 time in total.
Try to catch fish rather than asking for some fishes.

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11686 How can

Post by saiful_sust » Sun Oct 18, 2009 12:00 pm

Thanks 4 ur reply ...
But sorry to say my programme don't work
.............Here is my code

Code: Select all

CUT After ACC......... :D 
Last edited by saiful_sust on Mon Oct 19, 2009 5:32 am, edited 1 time in total.

Post Reply

Return to “Volume 116 (11600-11699)”