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
Post
by saiful_sust »
Some PLZ help me .........
I am try to solve this problem and got WA
Here is my code....
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:
Post
by arifcsecu »
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:
Post
by arifcsecu »
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
Post
by saiful_sust »
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
Post
by saiful_sust »
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:
Post
by arifcsecu »
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
Post
by Igor9669 »
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
Post
by saiful_sust »
Thanks arifcsecu and Igor9669 4 ur reply
But i got WA again ...I feel boring with this problem...
Some one PLz help me.
-
helloneo
- Guru
- Posts: 516
- Joined: Mon Jul 04, 2005 6:30 am
- Location: Seoul, Korea
Post
by helloneo »
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
Post
by saiful_sust »
Thanks helloneo...for ur post
But still i got WA...
Here is my code..................
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:
Post
by arifcsecu »
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:
Post
by arifcsecu »
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
Post
by saiful_sust »
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:
Post
by arifcsecu »
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
Post
by saiful_sust »
Thanks 4 ur reply ...
But sorry to say my programme don't work
.............Here is my code
Last edited by
saiful_sust on Mon Oct 19, 2009 5:32 am, edited 1 time in total.