iamdumb's blog

By iamdumb, 9 years ago, In English

Hi! I just got this question and don't know if this is stupid or really challenging.I am getting 0 marks always.I am posting this just for fun here :P .Tell me your high score for this.

Update :- Guys this is some sort of challenge to all.Post your score if you want.I am not asking for help in this question.This is just for fun and challenge.Btw thanks and sorry to all who came out for help.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

Hello guys,Few days ago this question was asked in Codechef cookoff.I was able to understand greedy part of the editorial but could not convince myself with DP approach.

Things I did not understand, In the picking of Pairs,where are we checking the conditions in which pair's difference is strictly less than D.I could not see it anywhere.

So basically I want you to please explain it to me.The more detailed the more helpful(as I am dumb :P).Thank you have a nice day.

[](https://discuss.codechef.com/questions/72500/sumpair-editorial)

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

I have seen many time people starting dfs with starting node -1 but I don't understand why do they do this.Can you please tell me why do they do so like in this example.

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

This might be very vague,stupid and nonsense question but I want to ask.I have learnt how to make own Comparators.So can anybody please mention some links of question which can require to make our own comparetor function :)

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

Hello guys,I tried this question(Big Mod) but what keeps me irritating is that I think it is efficient way to do.But still it keeps on giving me WA.I request you to please have a look at this submission

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

I was doing this question from spoj.And as far as I have understood it,it requires to find lexiographically smallest toposorting of a DAG.I have studied toposorting from here but implementing it leads me to different toposorting.Can anybody explain me is there any way to find lexiographical toposort ?

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

Hello everyone,I was trying to do this question from spoj.First I had no idea how to do this question so,I googled and algorithms that came out was this

Algorithm: Run BFS from any node to find the farthest leaf node. Label that node T. Run another BFS to find the farthest node from T. The path you found in step 2 is the longest path in the tree.

But my problem is that it is becoming really very difficult to implement what is asked.Can anybody show me the code what is asked.Preferably in C++ and using dfs.Thanks.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

Hello everyone,I have just learnt segment tree(range sum and range min/max).I tried first segment tree question which is this.But I am getting what value should I assign to the parents while building the tree.I know What to assign to leaf nodes but not getting to the parent.Here I am facing problem

void build(string &s,int pos,int low,int high)
{
    if(low==high)
    {
        tree[pos]=s[low]-'0';
        return;
    }
    int mid=(low+high)/2;
    build(s,2*pos,low,mid);
    build(s,2*pos+1,mid+1,high);
    tree[pos]=                    //Here ?? What should be in this place
}

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By iamdumb, history, 9 years ago, In English

Hello everyone,Can you assist me ? I want code(c++) for cycle detection in graph using recursive dfs.I know there are many resources available out there but either they are not well explained or too Hi-fi for me.It would be best if you can add some comments if possible.

P.S : I know union find Data structure but still I would like to know some more application of dfs.Please help me in this regard

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By iamdumb, 9 years ago, In English

Hello everyone,I have just learnt bipartite graph and I thought to solve this question with that only.Before this I have never ever solved graph problems and this is my very first.Can anybody tell me whether my approach is right or wrong ?And if wrong what should I do to correct it.

P.S- I have seen people saying,It is classical DP problem and so.But I don't know single word about DP.So please help me with this using graphs only.Thank you

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By iamdumb, 9 years ago, In English

Can anybody please help me with this question.I know how to calculate shortest path but I have no idea how to actually trace the nodes in the shortest path.What modification to naive dijktra's has be made?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By iamdumb, 9 years ago, In English

Hello guys,I was doing this graph theory problem which requires simple bfs.I have few issues with this hope you can help me out.

P.S-I have seen its solution on web and I cannot understand why we are doing bfs from every node?? And summing maximum of red and black everytime.Please see my solution v/s one i found on web.Thank you

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By iamdumb, 10 years ago, In English

Hello,i have just started to learn Segment trees and for me to do GSS1 & GSS3 from spoj i have to learn how to calculate Maximum sub-segment sum.Can anybody suggest me some resource where i can get the full information except e-maxx(google translate is making a big mess).Or can anybody explain me here only if you have some time.I don't get why using structure and what's going on ??

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By iamdumb, 10 years ago, In English

hello,I am very uncomfortable with not just this question but all question this kind.What is the key idea or what should i do to get better at these kind of question?Thanks

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

By iamdumb, 10 years ago, In English

Hello,i learned Dijkstra's algorithm for finding ShortestPath to all vertices.I learned adjacency Matrix version from this source.I have a little doubt that how to find shortest path when we have our vertices not a single number but a pair of two numbers,more specifically say a coordinate(x,y).How to modify our original dijkstra's to solve this.This question needs above modification

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By iamdumb, 10 years ago, In English

hello you awesome people.I am studying divide and conquer technique nowadays.I am not getting in what scenario i have to use it.I have seen few algorithms like sorting(merge,quick),searching(binary) and few more..still i am not getting how to make my own divide and conquer algorithm for questions like finding largest element of array,maximum subset sum,multiplying polynomials,etc..

My few doubts 1) In what scenarios/problems Do i force myself to think Divide and conquer way ? 2) How to frame my own divide and conquer solution ?

I will be Obliged.Please Help.

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

By iamdumb, 10 years ago, In English

Hello,i was trying to learn hashing.But unfortunately i didn't find any good tutorial.Can anybody please give me a link or two of good hashing tutorial and most importantly its implementation in c/c++. Looking forward for help.

Have a good day.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By iamdumb, 10 years ago, In English

Can anybody please tell me how do i approach this question Two-Buttons using BFS. I know how to do this other way but not using BFS(new to graph algorithms :) ).And why did we use BFS not DFS.In what scenario we use DFS and in What BFS.Thanks

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it