Hacking Java 8 QuickSort

Revision en1, by macaquedev, 2025-02-09 23:00:36

Hi guys!

In the last div3 I hacked a couple of submissions that used quicksort. For some reason, I'm failing this time.

305347283

This submission uses an array of primitives, then uses Array.sort() which should be hackable. My generator is as follows

std::vector<int> anti_sort(size_t n) // 2n + 1
{
    std::vector<int> res(2 * n + 1);
    std::iota(res.begin(), res.end(), 1);
    // std::reverse(res.begin(), res.end());
    for (size_t i = n; i-- > 0;)
    {
        std::swap(res[2 * i + 1], res[i + n]);
    }
    return res;
}

signed main(void)
{
    auto v = anti_sort(99999);

    cout << "1" << endl;
    cout << "199999 1" << '\n';
    for (int i=0; i<v.size(); i++) 
        cout << v[i] << endl;
    return 0;
}

Why does the hack not work? And can someone suggest a hack that WILL work?

Tags hacking, java

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English macaquedev 2025-02-09 23:00:36 883 Initial revision (published)