제출 #1172121

#제출 시각아이디문제언어결과실행 시간메모리
1172121Hurryup_7735Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
13 / 100
440 ms26112 KiB
//In The Name Of ALLAH! #pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define ld long double #define endl '\n' #define pb push_back #define pf push_front #define speedyboy ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define bpc __builtin_popcount #define all(x) x.begin() , x.end() #define allr(x) x.rbegin() , x.rend() #define F first #define S second #define pll pair<ll , ll> #define turtle tuple<ll , ll , ll> #define pss pair<string , string> #define YES cout << "YES" << endl; #define NO cout << "NO" << endl; #define ordered_set tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> const ll sz = 1e6 + 5 , INF = 1e18 , MOD = 998244353; ll a[sz] , lg[sz] , pw[sz] , st[sz][20]; ll query(ll l , ll r){ ll x = lg[r - l + 1]; return max(st[l][x] , st[r - pw[x] + 1][x]); } ll mask , i , j , o; void solve(){ ll n , q; cin >> n >> q; for(i = 1 ; i <= n ; i++) cin >> a[i]; ll l = 1; vector<ll> v1 , v2; for(i = 1 ; i < n ; i++){ if(a[i] > a[i + 1]){ v1.pb(l); v2.pb(i); l = i + 1; } } v1.pb(l); v2.pb(n); while(q--){ ll l , r , k; cin >> l >> r >> k; bool ok = false; ll itr = lower_bound(all(v2) , r) - v2.begin(); if(itr < v2.size()){ if(v1[itr] <= l && r <= v2[itr]){ ok = true; } } cout << ok << endl; } } signed main(){ lg[1] = 0; for(i = 2 ; i < sz ; i++) lg[i] = lg[i / 2] + 1; for(i = 0 ; i < 20 ; i++) pw[i] = 1 << i; speedyboy; //open; ll t = 1; //cin >> t; while(t--){ solve(); } } /* 5 2 7 8 9 10 11 1 3 6 2 5 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...