#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <cstdio>
#include "secret.h"
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif
void print(long long t) {cerr << t;}
void print(int t) {cerr << t;}
void print(string t) {cerr << t;}
void print(char t) {cerr << t;}
void print(double t) {cerr << t;}
void print(long double t) {cerr << t;}
void print(unsigned long long t) {cerr << t;}
template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T> void print(deque <T> v);
template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";}
template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(queue <T> q) {cerr << "[ "; while(!q.empty()) {print(q.front()); cerr << " "; q.pop();} cerr << "]";}
template <class T> void print(priority_queue <T> q) {cerr << "[ "; while(!q.empty()) {print(q.top()); cerr << " "; q.pop();} cerr << "]";}
template <class T> void print(deque <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(int n__, T arr[]) {cerr << "[ "; for(int i = 0; i <= n__; i++) {print(arr[i]); cerr << " ";} cerr << "]\n";}
#define pb push_back
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define noAnsw cout << -1 << '\n'
#define ll long long
#define ppb pop_back
#define OK cout << "OK" << endl;
#define ld long double
#define all(v) (v).begin(), (v).end()
#define MP make_pair
#define PII pair <int, int>
#define endl '\n'
#define ull unsigned long long
#define PLL pair <ll, ll>
#define PIL pair <int, ll>
#define PLI pair <ll, int>
#define rall(v) (v).rbegin(), (v).rend()
#define priora priority_queue
#define urishOK cout << "urishOK\n";
void setIO(string name = "") {
if (!name.empty()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
void fastIO(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
}
void setPrecision(int x){
if(x == 0){
return;
}
cout.setf(ios::fixed);
cout.precision(x);
return;
}
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5, mod = 1e9 + 7, wmod = 998244353;
const double epsilon = 0.000001, pi = 3.14159265359;
const int N0 = 1005, LOG = 15;
int dat[LOG][N0], mask[N0], a[N0];
void DaC(int l, int r, int layer){
if(l >= r) return;
int mid = (l + r) / 2;
dat[layer][mid] = a[mid];
for(int i = mid - 1; i >= l; i--){
dat[layer][i] = Secret(dat[layer][i + 1], a[i]);
}
for(int i = mid + 1; i <= r; i++){
dat[layer][i] = Secret(dat[layer][i - 1], a[i]);
mask[i] |= (1 << layer);
}
DaC(l, mid - 1, layer + 1);
DaC(mid + 1, r, layer + 1);
}
void Init(int N, int A[]){
for(int i = 1; i <= N; i++){
a[i] = A[i - 1];
}
DaC(1, N, 0);
}
int Query(int L, int R){
L++;
R++;
if(L == R) return a[L];
int lyr = __builtin_ctz(mask[L] ^ mask[R]);
return Secret(dat[lyr][L], dat[lyr][R]);
}
Compilation message (stderr)
secret.cpp: In function 'void setIO(std::string)':
secret.cpp:60:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
60 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
secret.cpp:61:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
61 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |