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

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

I was solving the problem Finding Routers in the practice session of APIO 2025. I intuited (guessed) the following solution.

code

It gives the full 100 points but I have no proof of its correctness. It has an obvious $$$n\log_2{l}$$$ upper bound on the number of use_detector calls. This accounts for the first 3 subtasks. I think this bound can be further improved to $$$2n\log_2(\frac{l}{2n})$$$. However, none of these bounds explain why it can solve subtask 4 within $$$7500$$$ queries.

I found this blog post but the commentor also had no proof of his solution. I also found this solution which caches the queries. I think (not sure) it asks the same queries as my solution. It might be easier to reason about.

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

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

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

In this problem, my solution (code starts at line 71) is getting Wrong Answer.
I read the editorial.
My solution is the same as the editorial but without binary search.
I wrote a stress test which compared my solution with the editorialists code.
Using large T for different values of N, I could find no case where my answer was different.

stress test code

I cannot find any mistake in my logic or implementation.
Any help would be appreciated.

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

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

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

I am stuck on this problem.

Problem Synopsis:
You are given an array A of size N.
Consider an undirected edge-weighted graph with N nodes numbered from 1 to N such that for any two nodes i and j there is an undirected edge between i and j with weight |i-j| * max(A[i], A[j]).
Find the weight of the shortest path between two given nodes X and Y.

Input Format:
The first line contains a single integer T, the number of test cases.
The first line of each test case contains three integers N, X and Y.
The second line of each test case contains N integers, A[1] A[2] ... A[N].

Output Format
For each test case, print a single integer, the weight of the shortest path, on a separate line.

I have a working solution for the first 3 subtasks but have run out of ideas for the last one.
Any help would be appreciated.

my solution

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

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

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

I recently came across this blog post and decided to try some of its problems. I am stuck on this problem. I can think of a naive O(n^2) solution by iterating through all pairs but do not see any redundancy in this solution. I cannot see a way to make it sub-quadratic (other than using the fact that 1 ≤ ai ≤ 2.5 * 10^6, maybe?). Any hints would be appreciated.

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

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