Do you have any suggestions? Below is my code. I do not have any idea what is wrong with my code.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
const int Length=22, HashSize=19019, HashFactor=17;
char Max[Length], Key[HashSize][Length], Val[HashSize][Length];
bool Used[HashSize];
int ...
Search found 4 matches
- Mon Jun 07, 2004 12:15 pm
- Forum: Volume 5 (500-599)
- Topic: 560 - Magic
- Replies: 12
- Views: 7652
- Fri Jun 04, 2004 11:43 am
- Forum: Volume 5 (500-599)
- Topic: 560 - Magic
- Replies: 12
- Views: 7652
- Fri May 14, 2004 10:31 am
- Forum: Volume 100 (10000-10099)
- Topic: 10000 - Longest Paths
- Replies: 160
- Views: 57082
Re: Topological Sorting
2. Dist(v) = -1 for all nodes, D(Source)=0.
If you put Dist[v] = -inf , then your algorithm should be accepted.
Actually, I handle -1 as -inf. The problem was not my algorithm, but the input. See the "Fixing mistakes" section for more details. Now I received "AC" with my algorithm.
If you put Dist[v] = -inf , then your algorithm should be accepted.
Actually, I handle -1 as -inf. The problem was not my algorithm, but the input. See the "Fixing mistakes" section for more details. Now I received "AC" with my algorithm.
- Thu May 06, 2004 6:56 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10000 - Longest Paths
- Replies: 160
- Views: 57082
Topological Sorting
I tried to solve the problem as follows:
1. Order the nodes topologically (we have an acyclic graph here).
2. Dist(v) = -1 for all nodes, D(Source)=0.
3. For all nodes v in that order:
- For all edges from v to x:
- if(D(v)+1>D(x))
- D(x)=D(v)+1
4. Output the node x with maximum D(x) (if there is ...
1. Order the nodes topologically (we have an acyclic graph here).
2. Dist(v) = -1 for all nodes, D(Source)=0.
3. For all nodes v in that order:
- For all edges from v to x:
- if(D(v)+1>D(x))
- D(x)=D(v)+1
4. Output the node x with maximum D(x) (if there is ...