제출 #342133

#제출 시각아이디문제언어결과실행 시간메모리
342133NurstanDuisengalievHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
0 / 100
1844 ms36076 KiB
// Nurstan Duisengaliev // не, не надо меня узнавать /*#pragma GCC target ("avx2") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("O3")*/ #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define ll long long #define all(x) x.begin(), x.end() #define in insert #define mp make_pair #define F first #define S second #define ppf pop_front #define pb push_back #define ppb pop_back #define pf push_front #define pii pair <int, int> #define pll pair <ll, ll> #define boost() ios_base::sync_with_stdio(0), cin.tie(0) #define sz(x) (int)x.size() using namespace std; //using namespace __gnu_pbds; //template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = (int)1e6 + 123; const int mod = (int)1e9 + 7; const ll INF = (ll)1e18 + 1; struct st { int ans, maxi, mini; }; st d[N * 4]; int n, q, a[N]; st merge (st f, st s) { st ans; ans.maxi = max (f.maxi, s.maxi); ans.mini = min (f.mini, s.mini); ans.ans = max (f.ans, s.ans); if (f.maxi > s.mini) ans.ans = max (ans.ans, f.maxi - s.mini); return ans; } void build (int v, int l, int r) { if (l == r) { d[v].ans = 0, d[v].maxi = d[v].mini = a[l]; return; } int mid = l + r >> 1; build (v * 2, l, mid); build (v * 2 + 1, mid + 1, r); d[v] = merge (d[v * 2], d[v * 2 + 1]); } st get (int v, int l, int r, int nl, int nr) { if (nl > r || l > nr) { st ok; ok.ans = 0, ok.mini = mod, ok.maxi = -mod; return ok; } if (nl <= l && r <= nr) return d[v]; int mid = l + r >> 1; return merge (get (v * 2, l, mid, nl, nr), get (v * 2 + 1, mid + 1, r, nl, nr)); } void solve () { cin >> n >> q; for (int i = 1; i <= n; i ++) cin >> a[i]; build (1, 1, n); while (q --) { int l, r, k; cin >> l >> r >> k; if (get (1, 1, n, l, r).ans > k) cout << 0 << '\n'; else cout << 1 << '\n'; } } main () { // freopen (".in", "r", stdin); // freopen (".out", "w", stdout); boost (); int TT = 1; // cin >> TT; while (TT --) { solve (); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sortbooks.cpp: In function 'void build(int, int, int)':
sortbooks.cpp:54:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   54 |  int mid = l + r >> 1;
      |            ~~^~~
sortbooks.cpp: In function 'st get(int, int, int, int, int)':
sortbooks.cpp:66:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   66 |  int mid = l + r >> 1;
      |            ~~^~~
sortbooks.cpp: At global scope:
sortbooks.cpp:81:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   81 | main () {
      |       ^
#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...