Submission #1092923

#TimeUsernameProblemLanguageResultExecution timeMemory
1092923NurislamHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
312 ms18000 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int long long template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } const int N = 1e5+50, inf = 1e18+200; //int mod = 998244353; //int mod = 1000000007; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng) void solve(){ int n, q; cin >> n >> q; vector<int> a(n+1, 0); for(int i = 1; i <= n; i++)cin >> a[i]; vector<int> pref(n+1, 0); for(int i = 1; i <= n; i++){ pref[i] = pref[i-1]; pref[i] += a[i] <= a[i-1]; } auto calc = [&](int l, int r) -> int{ if(l > r)return 1; return (pref[r] == pref[l]); }; while(q--){ int l, r, k; cin >> l >> r >> k; int ans = calc(l+1, r); cout << ans << '\n'; //cout << (ans <= k) << '\n'; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int tt = 1; //cin >> tt; while(tt--){ solve(); } }
#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...