Anarchy in the APSP: Algorithm and Hardness for Incorrect Implementation of Floyd-Warshall

Правка en3, от ko_osaga, 2024-04-15 06:43:32

Hello Codeforces! I just uploaded the first paper of my life to arXiv, and I'm happy to share this with the community, especially because it is very related to competitive programming.

Here is the presentation I gave in MIT Theory Lunch.

What's the problem?

Everyone knows the Floyd-Warshall algorithm for computing the shortest path, it goes like this:

rep(k, n) rep(i, n) rep(j, n) A[i][j] = min(A[i][j], A[i][k] + A[k][j]);

And everyone knows this incorrect variant of Floyd-Warshall. I certainly implemented this when I was learning CP, cause I kinda wanted to "fix the loop order".

rep(i, n) rep(j, n) rep(k, n) A[i][j] = min(A[i][j], A[i][k] + A[k][j]);

This is bad, it does not compute the shortest path. It does, however, compute "something". Imagine someone gives you a sparse graph and asks you to compute "something". Then that's actually harder than the correct variant because you can't run Dijkstra! What is this?!

But don't worry, with some observation, you can actually run some sort of Dijkstra:

Theorem 1.2: The "incorrect Floyd-Warshall matrix" can be computed with a single Dijkstra and a simple DP.

Then there's this really funny preprint by DEGwer and EnumerativeCombinatorics which basically says that "nobody cares about loop order cause you can run incorrect ones $$$3$$$ times." This makes total sense when you want to compute the correct matrix in a troll way. But what about the other way around? What if you want to compute the troll matrix, given that you can only use a very serious black box of Floyd-Warshall?

Theorem 1.3: The "incorrect Floyd-Warshall matrix" can be computed with $$$O(\log n)$$$ iteration of Floyd-Warshall plus $$$O(n^2 \log n)$$$ computation.

This is quite interesting if you have a context — it is conjectured that the all-pair shortest path can't be computed faster than $$$O(n^3)$$$ (by Floyd-Warshall) and breaking it will be a major breakthrough. I am basically suggesting one way to do this breakthrough — optimize incorrect Floyd-Warshall XD

Why did you do this??

In late January, I was in NYC (cuz I like there) and was sleeping on ksun48's couch. In the afternoon, I created a random Baekjoon OJ mashup, and one of those random problems was from the PA 2019 finals. We both spent quite a lot of time on this problem but could not solve it before I had to leave for dinner, which was weird because it didn't seem impossible per PtzCamp standings. Anyway, I upsolved it later (which later became proof of my Thm 1.2), and then I realized the intended solution is a bitset cheese, lol

The MIT theory group has this "30-minute lunch talk" where there is free food, and people discuss random stuff. In February there were not a lot of people giving a talk, and it was the beginning of semester so I think some troll CP stuff can be tolerated. So I prepared that presentation and gave a talk (at this point I had almost zero intention on publishing this on conference).

After the talk, jcvb informed me of a conference called "Fun with Algorithms" where I can actually publish these. Technically, as the intended one was bitset cheese, I have an original solution (amplified by the fact that ksun48 did not gave me hint even though I asked, wtf), so if I can overcome the tight deadline it was kind of a good idea. But that time, I only had Theorem 1.2, and submitting it looked a little disrespectful to this DEGwer paper, so I tried to prove Theorem 1.3. I succeeded, and it looked pretty good to me, so I submitted it and got an acceptance.

Теги solve, more, baekjoon, oj

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en8 Английский ko_osaga 2024-04-15 09:40:31 213
en7 Английский ko_osaga 2024-04-15 07:38:25 3 Tiny change: 'afternoon I wanted to' -> 'afternoon we wanted to'
en6 Английский ko_osaga 2024-04-15 06:45:33 29 Tiny change: ' afternoon, I created' -> ' afternoon I wanted to have some fun, so I created'
en5 Английский ko_osaga 2024-04-15 06:44:37 19 Tiny change: 'as in NYC (cuz I like there) and was s' -> 'as in NYC and was s'
en4 Английский ko_osaga 2024-04-15 06:43:47 0 (published)
en3 Английский ko_osaga 2024-04-15 06:43:32 98 (saved to drafts)
en2 Английский ko_osaga 2024-04-15 06:42:30 1560 Tiny change: 'ppened??\nOk, in late Jan' -> 'ppened??\nIn late Jan' (published)
en1 Английский ko_osaga 2024-04-15 06:21:59 2378 Initial revision (saved to drafts)