## Search found 23 matches

- Sun Oct 26, 2008 11:07 am
- Forum: Volume 115 (11500-11599)
- Topic: 11545 - Avoiding Jungle in the Dark
- Replies:
**13** - Views:
**4599**

### Re: 11545 Avoiding Jungle in the Dark

I didn't look into your code thoroughly, but check to see if you are handling "sleeping inside danger zone" properly. Yeah, you are right, I don't rest inside "danger zone" at all, though it is permitted to rest there during the day! thanks! Anyway, even after including that, my code gives WA! #inc...

- Sat Oct 25, 2008 7:38 pm
- Forum: Volume 115 (11500-11599)
- Topic: 11545 - Avoiding Jungle in the Dark
- Replies:
**13** - Views:
**4599**

### Re: 11545 Avoiding Jungle in the Dark

Your understanding of left of S to left of D is correct. That description was there to remove ambiguity of border regions between jungle and plain lands. It was implied that, you are strictly located on one land and one hour later, you will be located in the next, having no concern about the interm...

- Sat Oct 25, 2008 6:56 pm
- Forum: Volume 115 (11500-11599)
- Topic: 11545 - Avoiding Jungle in the Dark
- Replies:
**13** - Views:
**4599**

### 11545 - Avoiding Jungle in the Dark

I don't why my code gives WA! IMHO, I think that having S and D in the question really complicates the understanding of the problem. I still don't understand what is the nature of S and D. Are they plains? If they are plains, is the question about moving from left of S to left of D, or right of S to...

- Sun Sep 14, 2008 9:10 am
- Forum: Volume 114 (11400-11499)
- Topic: 11481 - Arrange the Numbers
- Replies:
**10** - Views:
**4602**

### Re: 11481 - Arrange the Numbers

Can you explain a little more?Robert Gerbicz wrote:Use inclusion-exclusion principle.

Inclusion and exclusion on what?

- Thu Feb 28, 2008 8:07 pm
- Forum: Volume 114 (11400-11499)
- Topic: 11404 - Palindromic Subsequence
- Replies:
**25** - Views:
**13892**

- Thu Feb 28, 2008 8:05 pm
- Forum: Volume 114 (11400-11499)
- Topic: 11404 - Palindromic Subsequence
- Replies:
**25** - Views:
**13892**

This problem could also be solved by modified Hunt-Szymanski algorithm, an algorithm for LCS. In this case, you could get the lexicographically smallest palindrome by calculating the lexicographically smallest LCS. If the algorithm you claimed is not based on the fact that all LCS must be palindrom...

- Tue Feb 26, 2008 10:49 am
- Forum: Volume 114 (11400-11499)
- Topic: 11404 - Palindromic Subsequence
- Replies:
**25** - Views:
**13892**

### Re: 11404 Palindromic Subsequence

But in this problem you have to print the lexicographically smallest palindrom, which is the longest, and you can do that in O(|size of alphabet|*n) time. (So the total time is O(n^2)) Can you explain how you print lexicographically least palindrome with O(|size of alphabet|*n) time? I thought hard...

- Sun Jan 06, 2008 1:14 pm
- Forum: Algorithms
- Topic: SPOJ MATRIX
- Replies:
**0** - Views:
**1366**

### SPOJ MATRIX

I am trying to solve this problem at SPOJ https://www.spoj.pl/problems/MATRIX/ My naive code which is O(n^4) searches exhaustively through all the submatrices and therefore gives TLE. I think, there must be some O(n^3) algorithm (as the one for maximal submatrix) to solve the problem. But I am not a...

- Sun Jan 06, 2008 12:57 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11377 - Airport Setup
- Replies:
**24** - Views:
**11862**

*Always* remember to test your code on sample I/O, especially before posting it here. It prints extra newlines. I got AC now Thanks a million! I added some debugging statements, and then I deleted them, but I forgot to remove the newline I had given as a part of that. I should have tested by redire...

- Sun Jan 06, 2008 12:05 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11377 - Airport Setup
- Replies:
**24** - Views:
**11862**

Here's one correct approach: let cost of directed edge a->b be 1 if b doesn't have an airport, and 0 otherwise; each undirected edge (a, b) corresponds to two symmetric directed edges: a->b and b->a. Then the answer is length of shortest path between x and y, plus 1 if x doesn't have an airport. I ...

- Sun Jan 06, 2008 10:49 am
- Forum: Volume 113 (11300-11399)
- Topic: 11377 - Airport Setup
- Replies:
**24** - Views:
**11862**

I first implemented BFS, but that gave WA, even after considering x == y case. So I implemented Djkstra noting that if x and y don't have an airport then the cost of path between them will be more than, if any one of them have airport which in turn will be more when, both have airport in it. Is this...

- Sun Dec 30, 2007 7:58 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11375 - Matches
- Replies:
**18** - Views:
**6947**

If u are using C style char array to store the number, make sure it is terminated by '\0'Leonid wrote:The sample of my outputCode: Select all

`0 1 2 4 .......`

I remeber doing such silly mistake in some other problem, which prevented me from getting AC

Better post the code, so that we could try to spot the bug.

- Tue Dec 04, 2007 9:43 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10061 - How many zero's and how many digits ?
- Replies:
**43** - Views:
**21381**

dear Antonio Ocampo, For number of digits, i did the following: for(sum=0.0,i=1;i<=n;++i) // change in indexing sum+=(log10(i)/log10(b)); // change // cout<<ceros(n,b)<<" "<<int(floor(sum/log10(b)))+1<<"\n"; cout<<ceros(n, b)<<" "; if (sum - floor(sum) < 1e-14) sum ++; else sum = floor(sum + 1); pr...

- Sun Nov 25, 2007 2:16 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11353 - A Different Kind of Sorting
- Replies:
**17** - Views:
**7553**

- Sat Nov 24, 2007 9:37 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11353 - A Different Kind of Sorting
- Replies:
**17** - Views:
**7553**

haha, I find that, when I put, char arr[MAX]; int s[MAX]; globally, then there is no run time error! Really strange. But I get WA! I think there must be some problem with the logic I use. Can anyone tell me, what is the output for the following inputs? 2000000 1999999 And I want to know for input ca...