Search found 17 matches

by kaushik_acharya
Sat Mar 22, 2014 6:34 pm
Forum: Volume 4 (400-499)
Topic: 452 - Project Scheduling
Replies: 23
Views: 10338

Re: 452, Why WA

brianfry713 wrote:Try changing your tokenize function. It throws a RE if there is a trailing space on a line. I used sscanf().
@brian,
Thanks a lot. I didn't realised that the input lines can have trailing spaces.
I made a change on my tokenize function to check for reaching end of string.
by kaushik_acharya
Fri Mar 21, 2014 8:07 pm
Forum: Volume 4 (400-499)
Topic: 452 - Project Scheduling
Replies: 23
Views: 10338

Re: 452, Why WA

Got RE.
Here's my code: http://ideone.com/f4nz44

Have done DFS based topological sort like others have mentioned in this thread.
Have also tested the code with the 100 test cases put by Brian Fry.

Wondering where could I have gone wrong.
by kaushik_acharya
Sun Mar 16, 2014 8:12 am
Forum: Volume 7 (700-799)
Topic: 750 - 8 Queens Chess Problem
Replies: 78
Views: 27711

Re: 750 - 8 Queens Chess Problem

I have received Presentation Error.
Here's my code:
http://ideone.com/a5GpMX

I am not sure what to change in my code.
by kaushik_acharya
Thu Oct 03, 2013 4:22 pm
Forum: Volume 101 (10100-10199)
Topic: 10107 - What is the Median?
Replies: 74
Views: 19861

Re: 10107 - What is the Median?

http://discuss.codechef.com/questions/1 ... sorting-it
This is a helpful discussion in another website where selection algorithm is suggested.
by kaushik_acharya
Fri Aug 16, 2013 12:01 pm
Forum: Algorithms
Topic: BigInt problem: got Wrong Answer
Replies: 4
Views: 2196

Re: BigInt problem: got Wrong Answer

Thanks for the help.

I realised my mistake.
Product of n digit number with another n digit number can go upto 2n digit number.
I should have taken this into consideration.
by kaushik_acharya
Sun Aug 11, 2013 6:47 pm
Forum: Algorithms
Topic: Expressions in postfix notation
Replies: 5
Views: 2763

Re: Expressions in postfix notation

This is what I had tried: #define MAX_STR_LENGTH 10001 class TreeNode { public: // functions to get and set the member variables private: char item_; TreeNode* parent_; TreeNode* left_; TreeNode* right_; } class Tree { public: void read_input(); void traversal(); void write_output(); private: TreeNo...
by kaushik_acharya
Sat Aug 03, 2013 2:57 pm
Forum: Algorithms
Topic: Binary Search Heap Construction
Replies: 0
Views: 2203

Binary Search Heap Construction

http://poj.org/problem?id=1785 I tried the recursive solution but got stack overflow for last two test case(http://www.informatik.uni-ulm.de/acm/Locals/2004/) (where input size is around 50,000) My method is as suggested here: http://www.stanford.edu/class/cs97si/assn3.html i.e. Find the root, divid...
by kaushik_acharya
Tue Jul 30, 2013 10:46 am
Forum: Algorithms
Topic: BigInt problem: got Wrong Answer
Replies: 4
Views: 2196

Re: BigInt problem: got Wrong Answer

Can you please check if my ans wrt n=100 is the only one that is incorrect or others also?
by kaushik_acharya
Tue Jul 30, 2013 10:45 am
Forum: Algorithms
Topic: Expressions in postfix notation
Replies: 5
Views: 2763

Re: Expressions in postfix notation

I redirected the stdout to a file as mentioned here:
http://www.mathinfo.u-picardie.fr/asch/ ... ction.html

$ myprog < myin > myout

I am still not sure why I am getting Time Limit Exceeded.
by kaushik_acharya
Mon Jul 29, 2013 3:25 pm
Forum: Algorithms
Topic: Expressions in postfix notation
Replies: 5
Views: 2763

Expressions in postfix notation

http://poj.org/problem?id=3367 Have received Time Limit Exceeded . My algo : 1. create the tree. 2. BFS traversal. Pushed the elements into string as the elements are visited. 3. reversed the string. I checked the Judges's comment from the original source http://www.informatik.uni-ulm.de/acm/Locals/...
by kaushik_acharya
Wed Jul 24, 2013 1:53 pm
Forum: Algorithms
Topic: BigInt problem: got Wrong Answer
Replies: 4
Views: 2196

BigInt problem: got Wrong Answer

http://poj.org/problem?id=2084 I got wrong answer for this problem. My algo and the implementation with my Big Int seems correct to me. For checking the values I printed all the cases in a file. Can anyone point me which case I am printing wrong answer: i = 1 :: connections: 1 i = 2 :: connections: ...
by kaushik_acharya
Sat Jul 20, 2013 8:43 pm
Forum: Algorithms
Topic: Knight Move from Point A to Point B (Time Limit Exceeded)
Replies: 2
Views: 2146

Re: Knight Move from Point A to Point B (Time Limit Exceeded

Thanks Brian.

I also got it using C++ STL queue. I think the mistake I did was precomputing possible moves from each square position.
This probably led to more time than assigned by online judge for some test cases in which the total no of steps from Point A to Point B were small.
by kaushik_acharya
Wed Jul 17, 2013 9:23 pm
Forum: Algorithms
Topic: Knight's journey (Time Limit Exceeded)
Replies: 2
Views: 2182

Knight's journey (Time Limit Exceeded)

http://poj.org/problem?id=2488 My solution: DFS with backtracking But I received Time Limit Exceeded Here's the pseducode: class Position { std::set<T> setJumpPos_; // possible positions to which the Knight can go from the current position. } class Board { std::vector<Position<T> > vecPos_; bool com...
by kaushik_acharya
Wed Jul 17, 2013 2:21 pm
Forum: Algorithms
Topic: Knight Move from Point A to Point B (Time Limit Exceeded)
Replies: 2
Views: 2146

Knight Move from Point A to Point B (Time Limit Exceeded)

Problem: http://poj.org/problem?id=1915 My solution: BFS traversal starting from point A till it visits point B. I received Time Limit Exceeded for my solution. I am not able to figure out if there's another more efficient solution. Hence asking for help here. I have used C++ STL queue. http://poj.o...
by kaushik_acharya
Wed Jul 03, 2013 6:16 pm
Forum: Algorithms
Topic: Nearest Common Ancestors
Replies: 2
Views: 2145

Re: Nearest Common Ancestors

Thanks Brian for the reply. I got AC with 266MS I misunderstood the reason for Time Limit Exceeded. Even when we iterate back, it will be done in O(n) (for search of nearest common ancestor after the tree is created). So the solution shouldn't get rejected. And that's true as I got my solution accep...

Go to advanced search