Search found 45 matches

by marcadian
Tue Oct 07, 2008 5:01 pm
Forum: Algorithms
Topic: Dynamic Programming -- Independent sets in tree
Replies: 1
Views: 1251

Re: Dynamic Programming -- Independent sets in tree

represent tree as undirected, but traverse as directed
0. 1 2
1. 0 4
2. 0 3
3. 2 4
4. 1 3 5
5. 4

Code: Select all

dfs(node,parent)
{
    foreach ( v adjacent to node)
        if (v!=parent) dfs(v)
}
by marcadian
Thu Oct 02, 2008 9:19 am
Forum: Volume 115 (11500-11599)
Topic: 11504 - Dominos
Replies: 55
Views: 19863

Re: 11504 - Dominos

My AC solution is failed with darko's case

Code: Select all

1
6 6
1 2
2 3
3 1
4 5
5 6
6 4
My AC code gives 2 instead of one. But this one give AC during contest :D
by marcadian
Thu Oct 02, 2008 8:49 am
Forum: Algorithms
Topic: use Bellman ford algo. to find a negative cycle
Replies: 5
Views: 3978

Re: use Bellman ford algo. to find a negative cycle

Code: Select all

for(;!used[firstchanged]; firstchanged  = parent[firstchanged])
{
path[++idx] = firstchanged;
used[firstchanged] = true;
}

print from the first occurence of firstchanged in path, until idx

by marcadian
Mon Sep 15, 2008 7:19 pm
Forum: Volume 114 (11400-11499)
Topic: 11487 - Gathering Food
Replies: 11
Views: 3705

Re: 11487 - Gathering food

Thx I got AC, my BFS doesn't consider if food is already taken than you can pass that point

Code: Select all

3
ABC
DEF
...
by marcadian
Mon Sep 15, 2008 3:25 pm
Forum: Volume 114 (11400-11499)
Topic: 11487 - Gathering Food
Replies: 11
Views: 3705

Re: 11487 - Gathering food

I'm try counting the way in the BFS, but it gets WA, can anyone give me test case ?Thx
by marcadian
Sat Jun 14, 2008 9:54 am
Forum: Volume 109 (10900-10999)
Topic: 10938 - Flea circus
Replies: 14
Views: 7767

Re: 10938 - Flea circus

My Solution get WA, can anybody give test case?? Here is my solution, i find LCA with reduce it to RMQ problem

Get AC without edit, I wonder why ? I think when I post my code here it gets WA in OJ but now get AC
by marcadian
Sat Aug 25, 2007 10:58 am
Forum: Volume 8 (800-899)
Topic: 851 - Maze
Replies: 35
Views: 16263

Code: Select all

 cut 
AC
by marcadian
Thu May 03, 2007 7:26 am
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17214

oh yes thank you for that and sorry for the code i've removed it, but the true mistake is I print "Impossible" it should be "Impossible." (with dot) what a silly mistake
by marcadian
Thu Apr 26, 2007 9:17 am
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17214

yeah i also think like that but i think if i move the boundary so i need not to check whether the i and j is valid will be same with ur code?? i change to this int lr,lc; lr = p.x + l; lc = p.y + l; int ii = p.x-l; int jj = p.y-l; for (i=ii;i<=lr;i++) for (j=jj;j<=lc;j++) if (i>0 && i<r && j>0 &&j<c...
by marcadian
Sun Apr 08, 2007 4:22 pm
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17214

now it gets WA, could somebody give me test case?

Code: Select all

cut
by marcadian
Mon Apr 02, 2007 6:52 am
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17214

i've tried the test case and my program give same result, but it gets TLE can anybody help me?? here is my code

Code: Select all

cut
by marcadian
Sat Dec 09, 2006 7:42 am
Forum: Algorithms
Topic: swaping items algo problem
Replies: 5
Views: 2111

I think it can be done with simulate it, if it not in it's position, "carry" it to it's position and carry the one that occuppy the position before until all item in it's position example: 1 2 4 5 3 << you want to be 1 2 3 4 5 1 << in position next 2 << next 4 <<not in position, carry to it's posit...
by marcadian
Mon Dec 04, 2006 2:23 pm
Forum: Algorithms
Topic: swaping items algo problem
Replies: 5
Views: 2111

I think it can be done with simulate it, if it not in it's position, "carry" it to it's position and carry the one that occuppy the position before until all item in it's position example: 1 2 4 5 3 << you want to be 1 2 3 4 5 1 << in position next 2 << next 4 <<not in position, carry to it's positi...
by marcadian
Sat Nov 11, 2006 5:20 pm
Forum: Volume 108 (10800-10899)
Topic: 10880 - Colin and Ryan
Replies: 45
Views: 27580

I got WA, help me I have tried i/o in this topic

Code: Select all

AC
failed with this input
input
1
1 0
output
Case 1: 1
by marcadian
Mon Nov 06, 2006 7:57 am
Forum: Algorithms
Topic: i couldn't find any algo
Replies: 8
Views: 3236

oh yes, i'm sorry thank's 4 correct me.to find minimal number use BFS instead of DFS. @giorgi: could you explain this again?I'm not fully understand what you mean

Go to advanced search