vishwanth2002's blog

By vishwanth2002, history, 3 months ago, In English

https://codeforces.me/contest/2233/submission/377920491

crazy solution by PCTprobability ( how did you even think of this )

It is not hackable practicially but theoretically hackable.

but i still dont know the proof lol.

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

»
3 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Probably not theoretically hackable. Even though rand() is not seeded and you can perfectly predict all values of it in advance, the chance that an input exists where it fails like 100 times in a row (which is what you would need for it to TLE) is very close to zero.

I'm not sure how easy it is to prove that a random shuffle guarantees a certain % chance of success (probably find the chance that the four 1s collide, and then multiply by $$$n$$$ with union bound)

Upd: with simple python simulation

>>> def test(n: int, results: list):
...   l = [randint(1, n) for i in range(4)]
...   l.sort()
...   if l[0] == l[1] or l[1] == l[2] or l[2] == l[3]:  return
...   d1 = l[1] - l[0]
...   d2 = l[2] - l[1]
...   d3 = l[3] - l[2]
...   if d1 == d2 or d2 == d3 or d1 == d3:
...     results[1] += 1
...   else:
...     results[0] += 1

With 5M trials for n = 20000 I got a failure chance of 0.000296 per number, or at most 583% chance of failure total (this doesn't help). So I'm not sure how to prove the full statement. Maybe you can assume independence (although that's sketchy) and that will make the odds better

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

You can check official editorial of B, it mentioned some information about randomized solution that may help you.

»
3 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

the template code just keeps going .....

»
3 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

this was my solution 377963327

»
3 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

This was my simple solution 377941553

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My solution is the most simple I believe 377964093

»
3 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Before: "LGMs solve hard problems with elegant solutions." After seeing this code: "Never mind."

»
3 months ago, hide # |
Rev. 3  
Vote: I like it +1 Vote: I do not like it
//simpler sol'n to b
ll n;
    cin>>n;
    cout<<n<<" ";
    for(int i=1;i<=n;i++)cout<<i<<" "<<i<<" ";
    for(int i=1;i<=n;i++)cout<<i<<" ";
    for(int i=1;i<=n-1;i++)cout<<i<<" ";
    cout<<'\n';