## Search found 45 matches

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

### 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)
}
``````
Thu Oct 02, 2008 9:19 am
Forum: Volume 115 (11500-11599)
Topic: 11504 - Dominos
Replies: 55
Views: 20716

### 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
Thu Oct 02, 2008 8:49 am
Forum: Algorithms
Topic: use Bellman ford algo. to find a negative cycle
Replies: 5
Views: 4053

### 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

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

### 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
...
``````
Mon Sep 15, 2008 3:25 pm
Forum: Volume 114 (11400-11499)
Topic: 11487 - Gathering Food
Replies: 11
Views: 3883

### Re: 11487 - Gathering food

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

### 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
Sat Aug 25, 2007 10:58 am
Forum: Volume 8 (800-899)
Topic: 851 - Maze
Replies: 35
Views: 16549

Code: Select all

`` cut ``
AC
Thu May 03, 2007 7:26 am
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17733
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
Thu Apr 26, 2007 9:17 am
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17733
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...
Sun Apr 08, 2007 4:22 pm
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17733
now it gets WA, could somebody give me test case?

Code: Select all

``````cut
``````
Mon Apr 02, 2007 6:52 am
Forum: Volume 109 (10900-10999)
Topic: 10977 - Enchanted Forest
Replies: 42
Views: 17733
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
``````
Sat Dec 09, 2006 7:42 am
Forum: Algorithms
Topic: swaping items algo problem
Replies: 5
Views: 2172
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...
Mon Dec 04, 2006 2:23 pm
Forum: Algorithms
Topic: swaping items algo problem
Replies: 5
Views: 2172
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...
Sat Nov 11, 2006 5:20 pm
Forum: Volume 108 (10800-10899)
Topic: 10880 - Colin and Ryan
Replies: 45
Views: 28096
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
``````
Mon Nov 06, 2006 7:57 am
Forum: Algorithms
Topic: i couldn't find any algo
Replies: 8
Views: 3331
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