Блог пользователя sujal22514

Автор sujal22514, история, 3 месяца назад, По-английски

link to submission: https://codeforces.net/contest/1790/submission/277762835 link to problem : https://codeforces.net/contest/1790/problem/G

I have been trying to solve it for few hours now. I am getting wrong answer on test-case 5 sub-test : 1634

My approach is similar to what is given in the editorial. My approach is: first I run a breadth first search to find the nearest vertex with token in it and it's path contain only bonus. I take the dis vector to keep it's distance from 1. Then i want to check if there is a edge whose both endpoint is a bonus vertex. If so then is there an vertex with token in the neighbouring vertex of that edge(excluding the already found nearest to 1). If there is then answer is definitely yes.

Otherwise: for each bonus vertex find the number of token near it. and these would be the number of moves I can make to help reach nearest token to token 1.

I am not sure what I am doing wrong . If you have any advice on how solve it please help. Thanks.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор sujal22514, история, 4 месяца назад, По-английски

Problem Link : https://cses.fi/problemset/task/1750 Submission Link : https://cses.fi/paste/f2a12df5ba1948a496b5bf/

I am not sure why my code this TLE on one test case (where N and Q are 10^5). I tried doing it using binary Lifting , The matrix A is used to store descendants at 2^j position where j<= 35

I believe the solution should not take more then O(q*35+35*n) steps.

Can someone Please help me out?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится