kaiyu's blog

By kaiyu, history, 3 years ago, In English

1573C - Book

My idea is to use topological sort using BFS and output the max level the BFS reaches.

During BFS, If the indegree of child becomes 0, and the child's node number is greater than the parent node number, i'll push it into the queue without changing the level because this chapter will be understood in the current iteration itself . If the child's node number is lesser, i'll increment the level and push it into the queue because this chapter will require one more iteration to understand.

This solution fails on some case. What's wrong in this solution?

Here is my submission : 129318461

Full text and comments »

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

By kaiyu, history, 5 years ago, In English

Problem: https://mirror.codeforces.com/contest/1362/problem/A

My Submission: https://mirror.codeforces.com/contest/1362/submission/82595064

Test Case which it fails on: 7 576460752303423481

Correct Answer: -1

Answer when you run it locally:-1

Answer by Codeforces System:1

You can check the test case details of my submission.

Why Codeforces gives WA on this code?

I ran the code on CLion by JetBrains.

Also I ran it on Codeforces Custom Invocation:

It gave -1 as expected, but while testing my code idk why it gave WA.

Full text and comments »

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

By kaiyu, history, 5 years ago, In English

For 1100C - NN и обман зрения, how do we solve it using Binary Search?

Any good articles/videos on Binary Search?

Full text and comments »

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

By kaiyu, history, 5 years ago, In English

Problem Link:

https://www.codechef.com/problems/GRHARSH

I see all the solutions have 2D dp solution.

I was thinking dp[i] = max gold at the time i.

Is this correct?How to solve it using 1-D dp?

Full text and comments »

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

By kaiyu, history, 5 years ago, In English
  • Vote: I like it
  • +3
  • Vote: I do not like it