Блог пользователя Tabriz-Talayi

Автор Tabriz-Talayi, история, 7 дней назад, По-английски

I was recently tasked with finding a way to calculate SCCs in a directed graph by a teacher expecting me to reach Tarjan's or Kosaraju's algorithm, but I reached a completely different and new solution (the novelty Im not fully sure).

It's arguably a bit worse in both simplicity and complexity, but I decided to write a blog about it anyway since I think I used some cool ideas, and who knows, maybe somebody else can utilize this either to find a useful variant or in some completely unrelated problem.

My teacher named it KS-SCC, hinting at the fact that it's dumb/useless (in Farsi), lmao.
I think it's funny, so I will stick with it.


Prerequisites

Idea & Intuition + Proof of KS-SCC

Implementation of KS-SCC

KS-SCC Test Results (Complexity & Correctness)

I might have made a bigger deal out of this than it is but it was really fun for me to write this blog so I hope it was worthwhile.
I did not find anything similar by doing a quick search online but if anybody found an earlier discovery of the same solution they can share in the comments.

I checked everything I said multiple times to make sure whatever I said is correct, but I'm relatively in the beginning of my CP journey(8 months in) so if a more experienced coder can check what I said, I would truly appreciate it.

Also, I'm not technical enough and don't even think I have the required specs to run my own tests so I used ChatGPT for testing KS-SCC, and was overjoyed to see it outperformed Tarjan and Kosaraju at least for $$$n, m \lt = 10^5$$$ but I am not sure how trustworthy it is so if anybody is willing to test my code I will be eternally grateful.

This is the first version of KS-SCC and I did not spend much time on optimizing it, for instance I think the up[] array can be fully eliminated.

So I'm open to any and all suggestions for edits & optimization.

UPD1:
Im examining it along with DFS Tree to come up with a simpler explanation, In the meantime if anybody is struggling on grasping the concept i will be happy to answer any questions they have in my messages.
Im also attempting to write the full proof myself but take this with a grain of salt since I doubt I would be able to come up with and adequate proof.

And btw does anybody know what are the requirements on making it into Catalog? Is it even possible for me given that im a specialist?
If anybody has any info on this i would be extremely thankful if they could help me.

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

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

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

Context:
I recently learnt MST and reached this problem (609E - Minimum spanning tree for each edge). I was stuck on it for like 2 days, and I only managed to come up with an $$$O(m\log m + mn)$$$ solution, which will obviously TLE. I decided to read some of my teachers'/friends'/top coders' codes to get some idea, but they all used some kind of heavy algorithm I haven't learnt yet (mostly LCA). I was ready to give up on the problem; I decided to hand-run the current algorithm I had one more time to look for improvements before giving up, and fortunately during hand-running I noticed a key property in the Kruskal algorithm which led to me coming up with an extremely clean sol.
It solves the problem in $$$O(m\log m + (n + m\log n)\log n)$$$ and uses the core Kruskal Algorithm plus a vector-based StoL DSU.
IDK if this is a well-known property or not, but after checking some submissions, I'm sure it's not a well-known approach for this problem.


The Property

Full Solution
Implementation

I'm new to CP and hand-wrote everything myself (I used AI just for notation and capitalization and stuff), so if anyone has a better way of explaining than I do, or if some of what I said is wrong or needs editing, please let me know and I will edit the blog to bring it up to standard.

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

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

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

If you haven’t been living under a rock, you probably know there’s an ongoing conflict involving Iran and the US, and Iran has been under a near-total internet blackout.

and im an informatics student in Iran :(

For a while, having internet access was basically impossible. After the ceasefire, people could only get online by paying around $30–50 for just 5 GB of internet. (Keep in mind that the average monthly income in Iran is about $300–500.)

So yeah, I was practically selling an arm and a leg just to get online and just look at the codeforces website (super fun!).

Until recently, internet access was mostly limited to government people + their friends/families. Around two weeks ago, they started giving limited access to college professors, businessmen, and doctors.and they called it “Pro Internet”. yes, literally a subscription for internet where practically nobody could buy it even if they wanted to, and you have to be selected just to pay for it, and even then you still can access the full internet. (dont you wanna be in iran rn?)

Because my parents are doctors, I was lucky enough to finally try this “Pro Internet.” by being among the selected few and still paying about $2 per 5 GB, you get limited access to certain websites and Telegram (again, super fun!).

So after getting incredibly lucky, I finally stopped paying absurd amounts for VPNs and started using this Pro Internet just for Codeforces.

Now fast forward to today’s contest.

I start the contest, submit Problem A, and immediately my internet dies. Two minutes later it comes back, I submit A again… and it dies again. this time it doesn’t come back.

After waiting 15 minutes, I finally decide to go buy one of those $30 VPNs again. I wait for the seller to activate my account, waste even more time, finally get online, and start solving B. I come up with a solution pretty quickly and submit it, thats when i realize i forgot to check whether A was even accepted.

Because of my immense luck, the moment I open the submission page, my internet dies AGAIN (having the time of my life btw). I message the VPN seller, no response. Then suddenly my Pro Internet comes back. I fix my A solution, go back to B, submit it… and the internet dies AGAINNNN.

Then the VPN comes back on. (with alot of praying btw)

like come on, mannnn. I might be low rated, but Im still a human and still care about my progress.

The main goal of this rant was honestly just to vent my frustration, but also maybe to encourage people to be a little nicer when talking to Iranians on Codeforces.

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

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