Search found 18 matches

by predicate
Mon Jul 13, 2015 6:40 pm
Forum: Volume 7 (700-799)
Topic: 736 - Lost in Space
Replies: 4
Views: 2257

Re: 736 - Lost in Space

the line lines N+2 through end of file causes a lot of confusion. For each dataset, scan the input for words until you find a blank link, this will denote the end of the data set. Also for each word, you have to print a blank line before you print the word you have to print an extra blank line betwe...
by predicate
Thu Jul 02, 2015 1:39 pm
Forum: Volume 9 (900-999)
Topic: 986 - How Many?
Replies: 7
Views: 4034

Re: 986 - How Many?

some random test cases for debugging:
input :

Code: Select all

3 1 2
10 3 2
10 5 4
20 5 4
20 1 2
20 0 1
output :

Code: Select all

2
2002
69
282172814
1767263190
2892818244
by predicate
Thu Jul 02, 2015 11:31 am
Forum: Volume 9 (900-999)
Topic: 926 - Walking Around Wisely
Replies: 20
Views: 11197

Re: 926 - Walking Around Wisely

some random test cases to help debug: input: 10 30 1 1 30 30 83 5 7 W 9 16 N 11 4 S 16 6 S 25 14 W 11 6 E 10 25 W 7 3 S 11 9 S 24 2 N 9 11 E 20 16 W 15 10 E 15 16 N 8 14 W 23 25 S 25 23 E 25 15 W 13 8 W 16 16 S 8 7 S 14 14 W 14 25 E 20 21 E 11 7 W 25 15 W 20 2 E 19 2 E 14 21 S 21 14 W 24 13 N 17 16 ...
by predicate
Sun Jun 28, 2015 8:37 am
Forum: Volume 8 (800-899)
Topic: 869 - Airline Comparison
Replies: 7
Views: 4703

Re: 869 - Airline Comparison

Shafaet_du wrote:

Code: Select all

4
a b
b c
D e
e F
5
e D
a b
b c
E F
a c
The output for this test case give above is wrong. It should be No.
by predicate
Tue Jun 09, 2015 7:12 pm
Forum: Volume 122 (12200-12299)
Topic: 12207 - That is Your Queue
Replies: 4
Views: 4532

Re: 12207 - That is Your Queue

Some radomly generated large test cases for debugging: input: 916997995 940 E 632358558 E 162646446 N N E 898886127 E 485390735 E 600905454 E 778180253 E 759864344 N E 621944545 E 771107558 N N E 579664811 E 629816220 E 3106171 N N N E 743544045 E 330124357 N N N N E 101665003 N E 488268431 E 663639...
by predicate
Sun Jun 07, 2015 8:09 pm
Forum: Volume 109 (10900-10999)
Topic: 10954 - Add All
Replies: 80
Views: 26697

Re: 10954

if the size of the array is n, you sort the array n times, so the worst case run time of your program is O(n^2 lg(n)) which will be TLE for the given max size of n, which is 5000. You cannot sort the array every time you add two numbers. Think of a better approach which decreases the runtime of your...
by predicate
Sun Jun 07, 2015 7:57 pm
Forum: Volume 1 (100-199)
Topic: 119 - Greedy Gift Givers
Replies: 145
Views: 23665

Re: 119-Greedy Gift Givers

Read the problem statement carefully.
The output for each group should be separated from other groups by a blank line.
by predicate
Sun Jun 07, 2015 7:55 pm
Forum: C++
Topic: PRESENTATION ERROR
Replies: 1
Views: 4595

Re: PRESENTATION ERROR

You should always tell the problem number before you put the up the code.
by predicate
Sun Jun 07, 2015 7:52 pm
Forum: Volume 124 (12400-12499)
Topic: 12403 - Save Setu
Replies: 1
Views: 1723

Re: runtime error

your code fails at the following input:

Code: Select all

4
   donate    1000
    	 report
 donate 500
   report
by predicate
Sun Jun 07, 2015 7:42 pm
Forum: Off topic (General chit-chat)
Topic: Dynamic Programming in C++
Replies: 2
Views: 29650

Re: Dynamic Programming in C++

I don't think the language will be a big concern when you are starting with DP. The skills that you will have to master are the ability to determine problem states and to determine the transitions from the current problem to its subproblem. You should become comfortable with recursion and writing re...
by predicate
Tue May 26, 2015 6:48 am
Forum: Bugs and suggestions
Topic: read efficiently in c++
Replies: 1
Views: 2472

Re: read efficiently in c++

I don't know the best way, but one of the ways is to use the getline function in c++ ( http://www.cplusplus.com/reference/string/string/getline/ ). Once you have read the line in a string, you can split it by passing that string to a stringstream and then using the extract ( >> ) operator ( http://w...
by predicate
Tue May 26, 2015 6:02 am
Forum: Algorithms
Topic: Why Do I get A Presentation Error PLZ HELP ASAP
Replies: 1
Views: 1208

Re: Why Do I get A Presentation Error PLZ HELP ASAP

You should at least tell the problem name and id before putting up your code.
by predicate
Tue May 26, 2015 5:50 am
Forum: Volume 103 (10300-10399)
Topic: 10328 - Coin Toss
Replies: 19
Views: 7265

Re: 10328 - Coin Toss

I wrote a recursive relation as follow : toss(n, c, m) = toss(n-1, c+1, max(c+1,m)) + toss(n-1,0,m) n = number of tosses left c = consecutive heads m = max number of consecutive heads that have occurred till now I wrote a dp solution for this problem and have checked the answers on http://www.udebug...
by predicate
Tue May 26, 2015 3:09 am
Forum: Volume 102 (10200-10299)
Topic: 10218 - Let's Dance !!!
Replies: 7
Views: 3927

Re: 10218 - Let's Dance !!!

The problem statement should be a little more clear. It took me a while to figure out what the problem statement actually wants to say. We have m men and w women who are identical and c candies which are not identical. So, we have to take into account the type of candies that people receive, the dis...
by predicate
Mon May 04, 2015 4:21 pm
Forum: Volume 100 (10000-10099)
Topic: 10083 - Division
Replies: 12
Views: 5589

Re: 10083 - Division

I was able to understand all the other conditions except these two :
  • if ((a-b)log10(t) + 1 >= 100) -> not an integer
  • if (a % b != 0) -> not an integer
can someone please give me mathematical proofs as to why the above two conditions are true.

Go to advanced search