i_am_eating_wa_and_tle's blog

By i_am_eating_wa_and_tle, history, 7 weeks ago, In English

As far as I know stack.push() have a O(1) time complexity but is it actually correct if I use a stack of string.

stack<string> stringStack;
string inputString;
while(cin >> inputString) {
    stringStack.push(inputString); // what is the time complexity of this line
}

Full text and comments »

By i_am_eating_wa_and_tle, history, 5 years ago, In English

Problem Link: LightOJ 1407

PDF LINK: click here

How to solve this problem. I know the basic algorithm of solving 2SAT problem. In the basic algorithm for (Xi ∨ Yi) the implications are

  1. ¬Xi => Yi

  2. ¬Yi => Xi

But here in this problem I can't figure out the implications of the relation stated in the problem. Can you please help me Solve this problem???

Full text and comments »

By i_am_eating_wa_and_tle, history, 6 years ago, In English

problem link: http://lightoj.com/volume_showproblem.php?problem=1308

For PDF click here

How to solve this problem? I have tried much but failed everytime.

Full text and comments »

By i_am_eating_wa_and_tle, history, 6 years ago, In English

Problem Link: http://lightoj.com/volume_showproblem.php?problem=1077

For pdf Click here

As the problem says to find the lattice points from (Ax, Ay) to (Bx, By).My idea was to find the number of solutions of the equation x * (Ay-By) — y * (Ax-Bx) = Ax * ( Ay-By) — Ay * (Ax-Bx) which is basically Extended Euclid. I got WA so many times. And after that I found this. But I can't understand why this problem can't be solved using Extended Euclid. Can anybody Please explain ? After solving this problem I thought either I don't understand Extended Euclid or there is a bug in my code.

Full text and comments »

By i_am_eating_wa_and_tle, 6 years ago, In English

Is it possible to find the last two non-zero digits of a factorial of a number ranges from 1 to (10^100)! ??????

Full text and comments »

By i_am_eating_wa_and_tle, history, 6 years ago, In English

UPD:Got AC

PDF LINK: http://lightoj.com/volume_showproblem.php?problem=1138&language=english&type=pdf Problem link: http://lightoj.com/volume_showproblem.php?problem=1138

I think the solution is the number of 5s as prime factor in N! But how to calculate them faster.

Full text and comments »

By i_am_eating_wa_and_tle, history, 6 years ago, In English

problem link: http://lightoj.com/volume_showproblem.php?problem=1098

PDF Link: lightoj.com/volume_showproblem.php?problem=1098&language=english&type=pdf

I think this problems solution is Summation of ((floor(N/i) — 1) * i) .But n is 10^9. It will definately get TLE if I precalculate or use loop.I think there exist something that I do not know yet.Please help me solve this problem. If I need to learn any theory/algorithm to solve this problem please mention it.

Thank you very much.

Full text and comments »

By i_am_eating_wa_and_tle, history, 6 years ago, In English

Problem link: http://lightoj.com/volume_showproblem.php?problem=1359

For PDF click here

I think this is a very interesting problem. It is a LightOJ problem and catagorized under LCA/RMQ. What can be the solution idea for this problem? I can't find one, please help.

Full text and comments »

By i_am_eating_wa_and_tle, history, 7 years ago, In English

Hello everyone

I was trying to solve this problem. I have tried to solve this problem about 18 hours but I failed.I think it can be solved using k-th shortest path algorithm but I can't find an understandable article on k-th shortest path algorithm.Can anyone please explain the k-th shortest path finding algorithm. I know the Dijstra's algorithm. Also, if it can be solved using other algorithm then please help me to know the algorithm.

Full text and comments »

By i_am_eating_wa_and_tle, history, 7 years ago, In English

Geometry is the most terrible word in my life. But now, I want to get rid of this terror. Please suggest me some beginner books on geometry.

Full text and comments »

By i_am_eating_wa_and_tle, history, 7 years ago, In English

In the Editorial "Divide by Zero and Codeforces Round #399 (Div. 1+2, combined)" the problem setter said PROBLEM B can be solved easily by using DIVIDE AND CONQUER strategy. How to learn this strategy????

Full text and comments »