![]() |
| | #1 |
| Registered User Join Date: Sep 2005
Posts: 14
| anyone know the solution? She decides to distribute the candies to them one by one, with a rule that if student A is teased by B, A can receive candy before B. But this is a troublesome and time consuming task as she is very busy. You are asked to help Emily by writing a program to find the order of students that satisfies the rule. Input The first line of the input file contains an integer N (2 £ N £ 100), the number of students. The students are numbered as 1 to N. The following N lines describe each student being teased by whom. In the Kth line of those N lines, the first integer M (0 £ M < N) contains the number of students who tease student K, and the next M integers are the student numbers who tease student K. Output The output file should contain the sequence of student numbers separated by a space that Emily can distribute the candies with the rule satisfied. If there is more than one solution, you are only required to output anyone of them. If there is no solution, output "No Solution". Sample Input 1 5 2 2 3 1 3 1 5 1 2 0 Sample Output 1 1 4 2 3 5 Sample Input 2 5 2 2 3 1 3 1 4 1 2 0 Sample Output 2 No Solution do anyone know how to solve this problem? |
| heeroyung is offline | |
| | #2 |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| I assume you can figure out input and output okay. Here's a hint for you. This problem uses a datastructure that represents a graph. |
| Rashakil Fol is offline | |
| | #4 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| > do anyone know how to solve this problem? This is a little story about four people named Everyone, Someone, Anyone, and Noone. There was an important job to be done and Everyone was sure that Someone would do it. Anyone could have done it, but Noone did it. Someone got angry about that because it was Everyone's job. Everyone thought that Anyone could do it, but Noone realized that Everyone wouldn't do it. It ended up that Everyone blamed Someone when Noone did what Anyone could have done
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #5 | |
| Registered User Join Date: Aug 2005
Posts: 1,265
| Quote:
I haven't heard that one before. | |
| Ancient Dragon is offline | |
| | #7 | |
| Registered User Join Date: Sep 2005
Posts: 14
| Quote:
| |
| heeroyung is offline | |
| | #8 | |
| & the hat of GPL slaying Join Date: Sep 2001
Posts: 5,730
| Quote:
| |
| Thantos is offline | |
| | #9 | |
| Registered User Join Date: Sep 2005
Posts: 14
| Quote:
| |
| heeroyung is offline | |
| | #10 |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| Are you familiar with graphs? Topological sort. |
| Rashakil Fol is offline | |
| | #11 |
| Registered User Join Date: Sep 2005
Posts: 14
| Topological sort what's the meaning of this word? |
| heeroyung is offline | |
| | #12 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| > what's the meaning of this word? Oh please tell me you've heard of google....
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #13 | |
| & the hat of GPL slaying Join Date: Sep 2001
Posts: 5,730
| Quote:
| |
| Thantos is offline | |
| | #14 | |
| Registered User Join Date: Sep 2005
Posts: 14
| Quote:
This question require us to find a correct order of students. This can be done by making an array, e.g. Code: student[5]={1,2,3,4,5}
(if you still don't trust me, you can ask me to explain. since my english standard is very low, i hope you can understand what i am saying above.) | |
| heeroyung is offline | |
| | #15 |
| Registered User Join Date: Sep 2005
Posts: 14
| no one help me.................. |
| heeroyung is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| K&R solution? | deadhippo | C Programming | 12 | 05-09-2008 06:36 AM |
| 'Solution' and 'Project' usage in VC++ | C+/- | C++ Programming | 2 | 01-13-2007 09:50 AM |
| My Unix/Linux SECURITY SOLUTION - pls read | bjdea1 | Linux Programming | 3 | 04-11-2004 09:28 PM |
| Solution - Israel and Palestine? | Vber | A Brief History of Cprogramming.com | 1 | 03-19-2003 08:27 AM |
| Speed Challenge, my solution: | RoD | C++ Programming | 11 | 03-17-2003 09:12 PM |