//chockolateman credit
#include<bits/stdc++.h>
#include <vector>
#include "hack.h"
using namespace std;
const long long S = 27777;
const long long N = 1000000000;
vector<long long> temp, xf, xs, xs1, xs2, y, di;
long long diff;
long long query_pair(int x)
{
temp.clear();
temp.push_back(1);
temp.push_back(1+x);
return collisions(temp);
}
int hack(){
xf.clear();
for(long long i=1; i <= S; ++i) xf.push_back(i);
xs.clear();
for(long long i=S*(N/2LL/S); i <= N+S; i += S) xs.push_back(i);
while ((int)xf.size() > 1 || (int)xs.size() > 1) {
if ((int)xf.size() > (int)xs.size()) swap(xf, xs);
int m = (int)xs.size();
xs1.clear();
for (int i=0; i < m/2; ++i) xs1.push_back(xs[i]);
xs2.clear();
for (int i=m/2; i < m; ++i) xs2.push_back(xs[i]);
y.clear();
for (auto el : xf) y.push_back(el);
for (auto el : xs1) y.push_back(el);
if (collisions(y) != 0) xs = xs1;
else xs = xs2;
}
diff = llabs(xs[0]-xf[0]);
for (long long d=2LL; d*d <= diff; ++d) {
if (diff % d == 0LL) {
di.push_back(d);
di.push_back(diff/d);
}
}
di.push_back(diff);
sort(di.begin(), di.end());
int dsz = (int)di.size();
for (int p=0; p < dsz; ++p) {
vector<long long> v;
v.push_back(1LL);
v.push_back(di[p]+1LL);
if (collisions(v) == 1) return di[p];
}
}
Compilation message (stderr)
hack.cpp: In function 'int hack()':
hack.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
60 | }
| ^
# | 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... |