# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069014 | Boycl07 | Secret (JOI14_secret) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i, n) for(int i = 1; (i) <= (n); ++i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "FFILL"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
const int N = 1e5 + 3;
const int LIM = (1 << 16) + 3;
const ll INF = 1e18 + 1;
const int LOG = 19;
int s;
struct SegTree
{
ll st[N << 1];
int n;
void init()
{
rep(i, 2 * s) st[i] = INF;
}
void update(int pos, ll val)
{
for(minimize(st[pos += s], val); pos >>= 1; ) st[pos] = min(st[pos << 1], st[pos << 1 | 1]);
}
ll get(int l, int r)
{
ll res = INF;
for(l += s, r += s + 1; l < r; l >>= 1, r >>= 1)
{
if(l & 1) minimize(res, st[l++]);
if(r & 1) minimize(res, st[--r]);
}
return res;
}
} St_left, St_right;
int n, m;
int a[N], b[N], c[N], d[N];
vector<int> zip;
int st[N][LOG + 1], pos[N];
int num_hint = 0;
int secret(int x, int y) {num_hint++; return x + y;}
void dnc(int l, int r, int stage)
{
if(l == r) return;
int mid = l + r >> 1;
st[mid][stage] = a[mid];
st[mid + 1][stage] = a[mid + 1]; pos[mid + 1] |= (1 << stage);
ford(i, mid - 1, l) st[i][stage] = secret(a[i], st[i + 1][stage]);
forn(i, mid + 2, r) st[i][stage] = secret(st[i - 1][stage], a[i]), pos[i] |= (1 << stage);
dnc(l, mid, stage + 1);
dnc(mid + 1, r, stage + 1);
}
void solve()
{
cin >> n;
dnc(1, n, 0);
cout << num_hint << endl;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int TC = 1;
if(fopen("note.inp", "r"))
{
freopen("note.inp", "r", stdin);
freopen("note.out", "w", stdout);
}
while(TC--)
{
solve();
}
return 0;
}