Submission #1246414

#TimeUsernameProblemLanguageResultExecution timeMemory
1246414radaiosm7Hack (APIO25_hack)C++20
68.70 / 100
93 ms2120 KiB
//chockolateman credit #include<bits/stdc++.h> #include <vector> #include "hack.h" using namespace std; const long long S = 31623; vector<long long> nums; vector<long long> temp; long long query_pair(int x) { temp.clear(); temp.push_back(1); temp.push_back(1+x); return collisions(temp); } long long many(long long k) { long long res = 0LL; for (long long l=1; l <= S; ++l) res += (l-1)/k; return res; } int hack(){ vector<long long> xf,xs,xf1,xf2,xs1,xs2,y; temp.clear(); if(true) { xf.clear(); xs.clear(); //nums.push_back(0); //make it 1-indexed for(int i = 1 ; i <= S ; i++) xf.push_back((xf.empty()) ? 1 : (xf.back() + 1)); for(int i = 1 ; i <= S ; i++) xs.push_back((xs.empty()) ? 2*S : (xs.back() + S)); } long long quer = collisions(xf); if (quer != 0LL) { long long l = 2LL; long long r = S; while (l < r) { long long m = (l+r)/2LL; long long v = many(m); if (v == quer) { l = m; break; } else if (v < quer) r = m-1; else l = m+1; } return l; } while ((int)xf.size() > 1 || (int)xs.size() > 1) { if ((int)xf.size() > (int)xs.size()) swap(xf, xs); int m; xs1.clear(); xs2.clear(); m = (int)xs.size(); for (int i=0; i < m/2; ++i) xs1.push_back(xs[i]); 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; } long long diff = llabs(xs[0]-xf[0]); vector<long long> di; 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:99:1: warning: control reaches end of non-void function [-Wreturn-type]
   99 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...