### ekzhang's blog

By ekzhang, history, 3 months ago, ,

Hello all,

Like you, I enjoy solving Codeforces problems on the go. However, sometimes I am not working on my computer with all my environment and setup. There are many automated problem parsers and test runners to help make solving Codeforces problems painless, but they all require a complicated installation process.

About a year ago, I was introduced to CS Academy, which I thought had an amazing interface for solving problems. It shows the problems and your code side-by-side, and you can automatically run your program on the example test cases. Also, there is auto-saving in case you accidentally close your window. Why can't we have this for Codeforces?

I couldn't find anything on the web that was easy to set up and fun to use, so I made my own online workspace at wkspace.herokuapp.com.

Here are some features:

• No sign-up or installation required
• Parses Codeforces problems and displays them side-by-side with code
• One click to run your code on all example test cases (for non-interactive problems)
• One click to submit your code to Codeforces (if logged in)
• Auto-saving of code in the cloud
• List workspaces you have recently edited
• Support for new versions of the most common languages (C, C++, Python, Java, Ruby)
• Configurable themes (Monokai, Dawn, Solarized)
• Configurable keybindings (Vim, Emacs)

I have been using and developing this myself for the past year, and it is fairly stable now, so I would like to share it with you. Please let me know if you have any feedback on how to improve it!

Note: The code is open source and available at https://github.com/ekzhang/wkspace.

Thanks to Herman Došilović for making the Judge0 API, which is used in this project.

• +419

By ekzhang, history, 18 months ago, ,

Hello everyone!

I would like to invite you to participate in the Plano West High School Programming Contest online round. It will be held on Saturday, February 9th at 15:00 EST.

The contest will be 3 hours long and scored by the sum of points for problems solved (harder problems worth more points). There will be a wide range of problem difficulties, from Codeforces Div3 level to about Div1 B/C. Competitors in the second and third divisions will most likely find it interesting.

The problems have been prepared by students at my school: me (ekzhang), Vincent Huang (tastymath75025), Autumn Tan, Wuyou Xie, Sam Ziegelbein, and Timothy Qin. We would also like to thank Kevin Meng (mtr361) and Maxwell Jiang (rocketscience) for helping test the round.

Please visit this link to register for the contest. The round will be held on HackerRank (binary scoring will be used), and a live scoreboard will be available.

Good luck and and have fun!

UPD: Contest starts in 10 minutes!

UPD 2: Contest is over, thanks to everyone for participating! We encourage you to try upsolving the problems; the model solutions, test data, and a PDF of the problem packet are available here: https://tinyurl.com/pwshpc

• +38

By ekzhang, history, 3 years ago, ,

I recently submitted twice to problem 865C/866C (same problem), Gotta Go Fast.

http://codeforces.com/contest/866/submission/30954904

http://codeforces.com/contest/865/submission/30956252

The first submission got wrong answer on test 1 on Codeforces. But I tested the solution both locally and on Ideone, and the answer was correct.

In the second submission my only change was adding the following one "useless" line of code to a for loop:

if (hi > 2 && hi < 1) cout << "this should never run" << endl;


It got AC.

My question is, why is this happening? I've tried debugging it locally and looking at the assembly, but there are no bugs when it runs on my local machine or on Ideone; it's only acting strangely on Codeforces. I've been staring at this code for many hours now thinking it might be undefined behavior, but I've tried many slightly different submissions (with long double, without the call to min) that work just fine without the extra useless if statement.

Tl;dr: I am utterly confused and would greatly appreciate if you could help me find where my UB is, or if there's some other problem with floating-point precision :-)

Thanks!

• +28

By ekzhang, history, 3 years ago, ,

Four team members from the US:

• Zhezheng Luo (C_SUNSHINE)
• Dhruv Rohatgi (pacu)
• Ben Qi (Benq)
• Eric Zhang (ekzhang)

• +78

By ekzhang, history, 4 years ago, ,

Hi, I am currently trying an O(n(sqrt n)(lg n)) to problem 375D using Mo's Algorithm and a Fenwick Tree. My initial solution got a time limit exceeded on test case 53, so I tried to optimize it.

To optimize, I made a couple of changes to my check() function, that is called every time the Mo's Algorithm window is slid 1 tree node. I was thinking that this would make the algorithm run faster since check is the part that is run the most (n^1.5 lg n times).

My second submission didn't end up working. In fact, somehow, my new submission got TLE on test case 5, which the previous code could solve in 150ms!

Can someone help me figure out what could've happened that would make this attempted optimization run 10x slower?

Original Submission: http://codeforces.com/contest/375/submission/18813131

Second Submission: http://codeforces.com/contest/375/submission/18813311

Thank you very much!

• 0

By ekzhang, history, 5 years ago, ,

Hi, could someone help me on this problem? I keep getting WA on test case 74, and I can't figure out why. This is my latest submission without debugging code.

My code works like this: I first turn all the replies into [L, R] ranges on the bottom row. Then I take all the "yes" replies, and use all of them to get an initial, single [lo, hi] bound on the exit node. I sort the "no" replies in ascending order of L, then iterate through them, while updating lo. If at any time, lo > hi, we can end the loop.

For each of the "no" replies, check if there's any gap between lo and L. If there is, those gaps are all possible exits, and deal with them like that. Regardless, set lo to be max(lo, R + 1) at the end of every loop, as we've handled all possible nodes  ≤ R.

At the end of the program, do some casework, and output different answers based on that.

The program works for the first 73 cases, but it outputs "Data not sufficient!" for test case 74, which is incorrect. Help finding the bug would be greatly appreciated!