Submission #1207078

#TimeUsernameProblemLanguageResultExecution timeMemory
1207078friendiksHack (APIO25_hack)C++20
Compilation error
0 ms0 KiB
#ifndef LOCAL #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC diagnostic ignored "-Wpedantic" #endif #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; auto seed = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937_64 rnd(1488); template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<typename T, typename V> using table = gp_hash_table<T, V>; using i128 = __int128; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; const ll INF = 2e18; const int inf = 2e9; const int maxn = 1e5; const int MOD = 988244353; const ld pi = acos(-1); const int P = 5167; const int L = 26; const ld EPS = 1e-7; template<typename T, typename V> void fill(T &container, V value) { for (auto &c: container) c = value; } int N; int SUM = 0; ll collision1s(std::vector<long long> x) { SUM += x.size(); map<ll, ll> mp; for (auto c: x) mp[c % N]++; ll ans = 0; for (auto [a, b]: mp) ans += b * (b - 1) / 2; return ans; } int bs = 64000; int hack() { ll cols = 0; vector<ll> A(bs); while (cols == 0) { map<ll, int> mp; for (int i = 0; i < bs; ++i) { while (mp[A[i]] > 0) A[i] = rnd() % (ll) (1e10) + 29638; mp[A[i]]++; } cols = collisions(A); } int Rpos = 0; for (int delta = (1 << 29); delta > 0; delta /= 2) { if (Rpos + delta > bs) continue; vector<ll> v; for (int i = 0; i < Rpos + delta; ++i) { v.push_back(A[i]); } if (collisions(v) == 0) Rpos += delta; } int Lpos = Rpos; for (int delta = (1 << 29); delta > 0; delta /= 2) { if (Lpos - delta < 0) continue; vector<ll> v; for (int i = Lpos - delta + 1; i <= Rpos; ++i) { v.push_back(A[i]); } if (collisions(v) == 0) Lpos -= delta; } ll k = abs(A[Lpos] - A[Rpos]); ll ans = INF; for (ll d1 = 1; d1 * d1 <= k; ++d1) { if (k % d1 == 0) { ll d2 = k / d1; if (collisions({1, 1 + d1})) { ans = min(ans, d1); } if (collisions({1, 1 + d2})) { ans = min(ans, d2); } } } return ans; } int main1() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int t; cin >> t; int mx = 0; while (t--) { SUM = 0; cin >> N; cout << hack() << "\n"; mx = max(mx, SUM); } cout << mx; }

Compilation message (stderr)

hack.cpp: In function 'int hack()':
hack.cpp:66:16: error: 'collisions' was not declared in this scope; did you mean 'collision1s'?
   66 |         cols = collisions(A);
      |                ^~~~~~~~~~
      |                collision1s
hack.cpp:75:13: error: 'collisions' was not declared in this scope; did you mean 'collision1s'?
   75 |         if (collisions(v) == 0) Rpos += delta;
      |             ^~~~~~~~~~
      |             collision1s
hack.cpp:84:13: error: 'collisions' was not declared in this scope; did you mean 'collision1s'?
   84 |         if (collisions(v) == 0) Lpos -= delta;
      |             ^~~~~~~~~~
      |             collision1s
hack.cpp:91:17: error: 'collisions' was not declared in this scope; did you mean 'collision1s'?
   91 |             if (collisions({1, 1 + d1})) {
      |                 ^~~~~~~~~~
      |                 collision1s
hack.cpp:94:17: error: 'collisions' was not declared in this scope; did you mean 'collision1s'?
   94 |             if (collisions({1, 1 + d2})) {
      |                 ^~~~~~~~~~
      |                 collision1s
hack.cpp: In function 'int main1()':
hack.cpp:115:1: warning: no return statement in function returning non-void [-Wreturn-type]
  115 | }
      | ^
hack.cpp:103:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  103 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
hack.cpp:104:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  104 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~