제출 #1205051

#제출 시각아이디문제언어결과실행 시간메모리
1205051MamedovHack (APIO25_hack)C++20
100 / 100
101 ms880 KiB
#include "hack.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define oo 1000000001
#define eb emplace_back
#define pb push_back
#define mpr make_pair
#define ln '\n'
#define ull unsigned long long
#define ll long long
#define all(v) v.begin(), v.end()
#define iospeed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


template <typename T> void show(vector<T> &v) {
  for (T i : v) {
    cout << i << ' ';
  }
  cout << ln;
}

int hack() {
  ll l = 1, r = 1e9;

  while (r - l > 2) {
    ll mid = (l + r) >> 1;
    //cerr << "l r = " << l << ' ' << r << ln;
    ll sz = (r - l + 1);
    ll sq = sqrt(sz / 2);
    vll x;
    sq += (sq & 1);
    mid += (mid & 1);
    for (ll i = 1; i <= sq; i += 2) {
      x.eb(i * (1ll << 29));
    }
    for (ll i = mid; i > l && i > mid / 3; i -= sq) {
      x.eb(i * (1ll << 29));
    }
    ll res = collisions(x);
    if (res) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  int res = (l + r) >> 1;
  while (!collisions({1, res + 1})) res *= 2;
  return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...