//chockolateman
#include<bits/stdc++.h>
#include <vector>
#include "hack.h"
using namespace std;
const long long S = 31623;
vector<long long> nums;
long long query_pair(long long x)
{
    vector<long long> temp;
    temp.push_back(1);
    temp.push_back(1+x);
    return collisions(temp);
}
long long query(long long l,long long r)
{
    vector<long long> temp;
    for(long long i = l ; i <= r ; i++)
        temp.push_back(nums[i]);
    long long res = collisions(temp);
    return res;
}
int hack(){
    if(nums.empty())
    {
        nums.push_back(0); //make it 1-indexed
        for(long long i = 1 ; i < S ; i++)
            nums.push_back(nums.back() + 1);
        for(long long i = 1 ; i <= S ; i++)
            nums.push_back(nums.back() + S);
    }
    random_shuffle(nums.begin()+1,nums.end());
    long long l = 1;
    long long r = nums.size() - 1;
    while(l < r)
    {
        long long mid = (l+r+1)/2;
        if(query(1,mid))
            r = mid-1;
        else
            l = mid;
    }
    r++;
    int n;
    for(l = r-1 ; l >= 0 ; l--)
        if(query_pair(abs(nums[r] - nums[l])))
        {
            n = abs(nums[r] - nums[l]);
            break;
        }
    vector<long long> temp;
    for(int x = 1 ; x <= n ; x++)
        if(n%x==0)
        {
            temp.clear();
            temp.push_back(1);
            temp.push_back(1 + x);
            if(query_pair(x))
                n = x;
        }
    return n;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |