z4120's blog

By z4120, history, 7 weeks ago, In English,

Upd: Fix a small bug. The old code for detecting contest phase is not sufficient.
Upd2: When you register (virtual) for a contest, the script will prompt you to download the pretest.

Code:

code

Usage:

  • Just install the userscript. It will only one when you're taking part in a virtual contest.
  • Currently only works on the "My submissions" page (/contest/ID/my)
  • For testing, you can append ?always_show=1 to the URL.
  • Appending ?mock_pretest_count=1 will pretend that all problems have between 10 and 20 pretests.
  • When you register (virtual) for a contest, the script will prompt you to download the pretest.

How it works:

  • Fetch every submissions
  • Check if there's any skipped/hacked solution such that there's no rejected test cases (like this) (then the number of pretest is the number of passed test of that submission)
  • Otherwise estimate the number by getting number of passed tests of solutions that fail on pretests/main tests of contestants.
  • After the number of pretest is calculated, it's easy to compute the pretest verdict. The number of pretest is stored for future usage, so it's necessary to download the data only once.

Known bugs:

  • Sometimes logging out fails for unknown reason. You can log out manually and then force-get the data.
  • It's not possible if there's not enough submission for that problem. (For instance, running the code says that there are at least 1 and at most 138 pretests for problem 566E)
  • If the user is taking part in a virtual contest, it's not possible to view the test cases of a submission. In that case it's necessary to log out the user.
  • Fetching every submissions just to get the number of pretests of the problems is slow. (This can be avoided by fetching only solutions in contest, given that there are currently ~20000 submissions but only 3585 in-contest ones for #566)
 
 
 
 
  • Vote: I like it
  • +86
  • Vote: I do not like it

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by z4120 (previous revision, new revision, compare).

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by z4120 (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

While the current approach works well, it's slow. MikeMirzayanov Consider adding a query for the number of pretests to the API, if it isn't trivial to add the pretest feature to virtual participation?

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Update: In the previous version the script doesn't work when the data is not fetched and the user is in a virtual contest. Now the issue is fixed.

I think it's not possible to change HTTP-only cookies in JavaScript, so I have to log the user out.