Submission #889938

# Submission time Handle Problem Language Result Execution time Memory
889938 2023-12-20T10:04:52 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 17752 KB
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define file(s) if(fopen(s".in","r")) freopen(s".in","r",stdin);freopen(s".out","w",stdout)
#define all(x) (x).begin(), (x).end()
#define len(x) (int)x.size()
#define tm (tl + tr >> 1)
#define ls v << 1, tl, tm
#define rs v << 1 | 1, tm + 1, tr
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define elif else if
#define F first
#define S second
#define int long long

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;

const int MOD = 1e9 + 7;
const int N = 2e5 + 7;
const int P = 911;
const ll INF = 1e18;

int rnd() {
	int x = rand() << 15;
	return x ^ rand();
}

int n, a[N], t[N << 2];

void upd(int pos, int val, int v = 1, int tl = 1, int tr = n) {
	if (tl == tr) {
		t[v] = max(t[v], val);
		return;
	}
	if (pos <= tm) upd(pos, val, ls);
	else upd(pos, val, rs);
	t[v] = max(t[v << 1], t[v << 1 | 1]);
}

int get(int l, int r, int v = 1, int tl = 1, int tr = n) {
	if (l <= tl && tr <= r) return t[v];
	if (r < tl || tr < l) return 0;
	return max(get(l, r, ls), get(l, r, rs));
}

int ql[N], qr[N], ans[N], k[N];
vector <int> act[N];

void GazizMadi() {
	int m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= m; i++) {
		cin >> ql[i] >> qr[i] >> k[i];
		act[ql[i]].pb(i); 
	}
	for (int i = n; i; i--) {
		for (int j = i + 1; j <= n; j++) {
			if (a[i] > a[j]) upd(j, a[i] + a[j]);
		}
		for (int it: act[i]) {
			int l = i, r = qr[it];
			ans[it] = (get(l, r) <= k[i]);
		}
	}
	for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
}

const bool Cases = 0;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	srand(time(0));
	int TT = 1;
	if (Cases) cin >> TT;
	for (int i = 1; i <= TT; i++) {
		//cout << "Case " << i << ": ";
		GazizMadi();
	}
}

Compilation message

sortbooks.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int)':
sortbooks.cpp:13:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 | #define tm (tl + tr >> 1)
      |             ~~~^~~~
sortbooks.cpp:51:13: note: in expansion of macro 'tm'
   51 |  if (pos <= tm) upd(pos, val, ls);
      |             ^~
sortbooks.cpp:13:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 | #define tm (tl + tr >> 1)
      |             ~~~^~~~
sortbooks.cpp:14:24: note: in expansion of macro 'tm'
   14 | #define ls v << 1, tl, tm
      |                        ^~
sortbooks.cpp:51:31: note: in expansion of macro 'ls'
   51 |  if (pos <= tm) upd(pos, val, ls);
      |                               ^~
sortbooks.cpp:13:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 | #define tm (tl + tr >> 1)
      |             ~~~^~~~
sortbooks.cpp:15:24: note: in expansion of macro 'tm'
   15 | #define rs v << 1 | 1, tm + 1, tr
      |                        ^~
sortbooks.cpp:52:21: note: in expansion of macro 'rs'
   52 |  else upd(pos, val, rs);
      |                     ^~
sortbooks.cpp: In function 'long long int get(long long int, long long int, long long int, long long int, long long int)':
sortbooks.cpp:13:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 | #define tm (tl + tr >> 1)
      |             ~~~^~~~
sortbooks.cpp:14:24: note: in expansion of macro 'tm'
   14 | #define ls v << 1, tl, tm
      |                        ^~
sortbooks.cpp:59:23: note: in expansion of macro 'ls'
   59 |  return max(get(l, r, ls), get(l, r, rs));
      |                       ^~
sortbooks.cpp:13:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 | #define tm (tl + tr >> 1)
      |             ~~~^~~~
sortbooks.cpp:15:24: note: in expansion of macro 'tm'
   15 | #define rs v << 1 | 1, tm + 1, tr
      |                        ^~
sortbooks.cpp:59:38: note: in expansion of macro 'rs'
   59 |  return max(get(l, r, ls), get(l, r, rs));
      |                                      ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12888 KB Output is correct
3 Incorrect 2 ms 12892 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12888 KB Output is correct
3 Incorrect 2 ms 12892 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 17752 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 15700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12888 KB Output is correct
3 Incorrect 2 ms 12892 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12888 KB Output is correct
3 Incorrect 2 ms 12892 KB Output isn't correct
4 Halted 0 ms 0 KB -