# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1246075 | KALARRY | Hack (APIO25_hack) | C++20 | 0 ms | 0 KiB |
//chockolateman
#include<bits/stdc++.h>
#include <vector>
#include "hack.h"
using namespace std;
map<long long,bool> done;
map<long long,long long> memo;
vector<int> nums;
long long query(long long x)
{
if(done[x])
return memo[x];
done[x] = true;
vector<long long> temp;
temp.push_back(1);
temp.push_back(1+x);
memo[x] = collisions(temp);
return memo[x];
}
int hack(){
done.clear();
memo.clear();
std::vector<long long> temp;
bool broke = false;
int counter = -1;
if(nums.empty())
for(int i = 1 ; i <= 500000 ; i++)
nums.push_back(i);
random_shuffle(nums.begin(),nums.end());
while(!broke)
{
temp.clear();
counter++;
temp.push_back(1);
temp.push_back(1 + nums[counter]);
if(query(nums[counter]))
broke = true;
}
int n = nums[counter];
for(int x = 1 ; x <= n ; x++)
if(n%x==0)
{
temp.clear();
temp.push_back(1);
temp.push_back(1 + x);
if(query(temp))
n = x;
}
return n;
}