- ID : UVA - 10305 - Ordering Tasks
- Language : Java , C++
- Status : Accepted - Accepted
- Type : Topological Sort.
- Time : 6 Hours.
- Solution :
- Source Removal Method or DFS
- Calculate in Degree.
- Use a queue and insert at first all edges with 0 in Degree those who must be finished first.
- Dequeue every time a node and decrease the in-degree of all it's neighbours as this node is considered to be removed from the queue or the task is done
- each time you decrease the degree of the node. check if this task is available now ( i.e it's degree is zero that means that all of it's dependencies is already finished.
- Problems :
- Check for special cases in the input. the m could be a zero and that what stopped me for 6 hours and I don't know what's wrong with my solution. I discovered that I have to remove the m!=0 condition from the while loop statement.
- I wasn't able to submit the DFS solution don't know what's the reason. but I decided to solve more problems for this period and come to this later
- Code :
This Blog is a Personal record for All The Algorithms Problems I've Solved. It shouldn't be taken as a reference for optimal solutions because I'm just a beginner.
Friday, March 4, 2011
UVA - 10305 - Ordering Tasks
Wednesday, March 2, 2011
UVA - 10147 - Highways
- ID : UVA - 10147 - Highways
- Language : Java , C++
- Status : TLE - Accepted
- Type : Graph MST.
- Time : 10 Hours.
- Solution :
- Find All Edges
- Kruskal's MST.
- Problems :
- JAVA TLE Sometimes has no solution so don't waste your time in trying to get a Java solution Accepted.
- Make sure the second minimum MST is larger than the Original MST.
- Solutions :
Tuesday, March 1, 2011
28th Feb Summary
- Problem Solved :
- UVA - 10307 - Killing Aliens in Borg Maze - MST - Accepted
- UVA - 11631 - Dark Roads - MST - Accepted
- UVA - 10600 - ACM Contest and Blackout - MST - Accepted
- CodeForces - 63A - Sinking Ship - Adhoc - Accepted
- CodeForces - 63B - Settlers' Training - Adhoc - Accepted
- Problems Trails:
- NONE
- Readings:
- NONE
- Contests :
- Rating : 1266 ( -76 )
- Problems Solved : 2
- Score : 1090
- Notes from mistakes today :
- On UVA always re-check multi-input problems weather I reset the storage or not.
- hashCode() & equals() must be implemented together.
- Use the custom Parser for Java Std Input in large data input problems to avoid TLE.
- keep a minimum rate of a new topic daily.
UVA - 10600 - ACM Contest and Blackout
- ID : UVA - 10600 - ACM Contest and Blackout
- Status : Accepted
- Type : Graph MST .
- Time : 2 Hours to Submission.
- Language : Java
- Solution :
- Find MST
- Find MST in every time you remove an edge from the Original MST
- Problems :
- Make sure the MST is not the Original MST by removing the edges from the original MST and looping through all edges.
- Make sure the second minimum MST is larger than the Original MST.
Labels:
10600,
ACM Contest and Blackout,
Graph,
MST,
Second MST,
Uva,
UVA - 10600 - ACM Contest and Blackout
Subscribe to:
Posts (Atom)