#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;
}
Compilation message
secret.cpp: In function 'void dnc(ll, ll, ll)':
secret.cpp:78:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
78 | int mid = l + r >> 1;
| ~~^~~
secret.cpp: In function 'int main()':
secret.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
106 | freopen("note.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
secret.cpp:107:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
107 | freopen("note.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccQFhXNe.o: in function `main':
secret.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccOTmYne.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccOTmYne.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `Init(int, int*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x30b): undefined reference to `Query(int, int)'
collect2: error: ld returned 1 exit status