Блог пользователя vishwanth2002

Автор vishwanth2002, история, 3 месяца назад, По-английски

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.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

the template code just keeps going .....

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

this was my solution 377963327

»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

This was my simple solution 377941553

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My solution is the most simple I believe 377964093

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

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

»
3 месяца назад, скрыть # |
Rev. 3  
Проголосовать: нравится +1 Проголосовать: не нравится
//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';