BinaryCrazy's blog

By BinaryCrazy, history, 5 years ago, In English

Hi Codeforces,

I have been doing competitive programming for a little over a year now, but one thing has become clear to me — my typing & coding skills are a hinderance, but probably not in the way you are thinking of.

My typing speed is really slow (only 61 WPM), because I type sentences rather quickly, type one character wrong in the entire sentence, realize that 1 second later, and subsequently waste 2 seconds correcting it.

Because of that problems that I solve in virtual contests transform from 2 minutes to 20.

Still, that isn't the last of my worries. I occasionally make unconscious errors, leading me to spend a good 10 minutes of my time weeding through my code and write print statements until the cause is found.

As a result ... a "first" blood problem quickly transforms into a fiftieth blood problem.

I have tried to improve myself by practicing on websites such as typeracer, but my typing mistakes have not decreased, even after a month of daily practice for 30 mins.

And I have no idea how to improve writing clean code.

I would really appreciate if anyone can give me tips on how to improve these two problems (how to quickly improve, what to target).

Thank you very much for your time and help

-BC

Full text and comments »

  • Vote: I like it
  • +55
  • Vote: I do not like it

By BinaryCrazy, history, 5 years ago, In English

Hi all,

I hope you are having a great day.

I was solving this problem, which is quite simple with the policy based Data Structure Ordered Set.

However, I wanted to create a Ordered Multiset, but I couldn't get it to work, as I could not erase from the resulting data structure.

Can someone please help me by giving me the code for the ordered_multiset which supports insertion,deletion, order_by_key, and size?

Thanks,

-BC

Edit 2: It finally worked! :) Yay, I solved the problem, but more importantly, I found out some important things when using an ordered_multiset.

You must include the following in your code, apart from everything else to use the ordered_multiset.

#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

Let's call our ordered_multiset om since its suuuuper annoying to type.

We can declare om with the following code: typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

Search: om.upper_bound({value, -1})

Insert: om.insert({value, om.size() })

Note that the second value of the insertion has to be unique, which is why I use size().

Delete: om.erase( om.upper_bound({value, -1}))

Yeah, just combining the Search with om.erase().

Finally, my solution: 77420177

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it

By BinaryCrazy, history, 5 years ago, In English

Hi all,

Hope you are having a great day. I found this question on HackerEarth, and received a "Partially Accepted" verdict, but have no idea why.

Can someone please explain where my logic is wrong? I have listed my logic below.


Logic

Sort all the values for which one needs to perform the HIT operations.

Next, for each value, binary search to find the last index that satisfies the following inequality:

a[i] — i >= x[i] (1 indexing)

We subtract that from the original value, and output the resulting array.

Implementation.


Thanks a lot for your time and help.

It is greatly appreciated.

Regards,

BC

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By BinaryCrazy, history, 5 years ago, In English

Hi all,

Hope you are all safe with the unfortunate events occurring throughout the world.

I was solving some problems on HackerEarth's CodeArena platform (1v1 other person, 1 problem, 20 mins, who ever gets more TCs wins) , when I came across this problem (the contest has ended). I have attached the screenshot of the statement to this post.

I first attempted to use combinatorics and math to solve it, but later changed to applying DP. However, I couldn't figure out a recurrence between the states (# of objects, # of groups).

I would really appreciate it if someone could lend a helping hand with the recurrence. Also, IF there is an easy mathematical solution to the problem, please share it.

Thanks for your help and time! BC

EDIT: Sorry, I assumed that the 'Add Image' feature automatically appended the image to the post. Attached below is the image.

Sample TC: Input: 4 2

Output 3

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By BinaryCrazy, history, 5 years ago, In English

Hello all,

I recently stumbled upon this USACO problem linked here for reference. However, I wasn't able to solve it. When I looked at the editorial (here) of the solution, I realized that my logic was the same, but I couldn't prove the inclusion-exclusion for higher orders (> 2 sets).

I would really appreciate it someome could prove the addition-subtraction logic used for inclusion exclusion.

Thank a bunch, and hope you have a great day!

[Edit] I realized it may not be clear what I am asking. To be more brief, how can I prove that you can get the number of distinct connections by adding all subsets of size 1, subtracting subsets of 2, adding 3 ... and so on.

-BC

Full text and comments »

  • Vote: I like it
  • -6
  • Vote: I do not like it

By BinaryCrazy, history, 5 years ago, In English

Hi all,

Hope you are having a magnificent day and are feeling well. I was using VSCode (nice cross platform IDE) when I came across CP extensions that many top CF users were using (such as Petr's TC extension in his IDE shown during the videos of CF rounds he records)

I was wondering which CP Extension for VSCode is most developed, has features specifically towards adding/creating TCs, and supports CP websites such as USACO, CF, and TopCoder.

Which VSCode extensions do you recommend using?

Thank you very much for your time, and, again, I hope you have a pleasant rest of your day.

-BC

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it