ttbao999's blog

By ttbao999, history, 5 years ago, In English

I have just found a very strange solution for CSES — Elevator Rides problem and I think there will be someone can hack this, please help xxx. https://cses.fi/paste/e5c0ddf5c0b47ad42a1d2f/

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

| Write comment?
»
5 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

this is my code, but I can't calculate the probability to get wrong answer.

»
5 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

This seems to work:

20 280
56 56 56 56 56 40 40 40 40 40 40 40 35 35 35 35 35 35 35 35

The idea is that you need to group together each block of the same number, so if you combine two different numbers, which is highly likely, then you immediately fail. The numbers are chosen so that you have a group of $$$5$$$ numbers, a group of $$$7$$$ numbers, and a group of $$$8$$$ numbers, each of which are all the same number, where each group adds up to the same total and the numbers are coprime so that they're forced to be in those groups.

The above testcase consistently fails the given code, but if you increase the number of iterations from $$$10^5$$$ to $$$10^6$$$ then it consistently passes. However, you can fail even $$$10^6$$$ iterations using the following similar case:

19 420
140 140 140 105 105 105 105 84 84 84 84 84 60 60 60 60 60 60 60

This case has a group of $$$3$$$ numbers, a group of $$$4$$$ numbers, a group of $$$5$$$ numbers, and a group of $$$7$$$ numbers.