#pragma region #pragma GCC target("avx2") #pragma GCC optimize("03") #pragma GCC optimize("unroll-loops") #include using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define endl "\n" #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define rep(i,a,b) for(int i=(a);i<(b);i++) #define PII pair #define PLL pair #define ALL(x) (x).begin(), (x).end() constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1; templateinline bool chmax(T &a, const T &b) { if (ainline bool chmin(T &a, const T &b) { if (b> n; rep(i,0,n) cin >> a[i]; vector inc; vector dec; int inc_left = 0; int dec_left = 0; rep(i,0,n) { if(i == n-1 or a[i] > a[i+1]) { inc.emplace_back(inc_left, i); inc_left = i+1; } } rep(i,0,n) { if(i == n-1 or a[i] < a[i+1]) { dec.emplace_back(dec_left, i); dec_left = i+1; } } // for(auto &[c, d]: inc) cout << c << d << " "; // for(auto &[c, d]: dec) cout << c << d << " "; int Q; cin >> Q; while(Q--) { int l,r; cin >> l >> r; auto [left, right] = *(upper_bound(ALL(inc), make_pair(l, INF))-1); // cout << left << right << endl; if(left <= l and r <= right) cout << 1 << " "; else cout << 0 << " "; auto [left1, right1] = *(upper_bound(ALL(dec), make_pair(l, INF))-1); // cout << left1 << right1 << endl; if(left1 <= l and r <= right1) cout << 1 << endl; else cout << 0 << endl; } return 0; }