×

# How to solve Spoj TOPOSORT problem?

 1 Please tell me - How to solve Spoj TOPOSORT problem? I have tried to solve this but getting wrong at 12 number case. My code. asked 31 May '17, 03:06 2★rashedcs 497●5●17●55 accept rate: 4%

 3 I have just solved this problem and was getting the same problem. The reason is that the question states - If there is a solution print the correct ordering, the jobs to be done separated by a whitespace. If there are multiple solutions print the one, whose first number is smallest, if there are still multiple solutions, print the one whose second number is smallest, and so on. To achieve this, you should use std::set instead of std::queue because then the vertices will always be taken in sorted order for processing and the goal of question will be achieved. Also use scanf/printf as cin/cout will give you a TLE (just as it has given me). The link to my solution (if you want to refer) is - http://ideone.com/l3Ynrz Hope this helps. answered 31 May '17, 09:23 3★prj18 56●1 accept rate: 50%
 1 I have used same method as @prj18 but still getting TLE after test case #12 Link to code -> https://notepad.pw/dushyant7917-topsort answered 18 Oct '17, 12:07 71●6 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,217

question asked: 31 May '17, 03:06

question was seen: 624 times

last updated: 18 Oct '17, 12:07