Submission #421888

# Submission time Handle Problem Language Result Execution time Memory
421888 2021-06-09T13:17:10 Z pavement Food Court (JOI21_foodcourt) C++17
21 / 100
472 ms 31828 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
//#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<iii, null_type, greater<iii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void read(int &v) {
	v = 0;
	char ch = getchar_unlocked();
	for (; ch < '0' || ch > '9'; ch = getchar_unlocked());
	for (; '0' <= ch && ch <= '9'; ch = getchar_unlocked())
		v = (v << 3) + (v << 1) + (ch & 15);
}

void read(ll &v) {
	v = 0;
	char ch = getchar_unlocked();
	for (; ch < '0' || ch > '9'; ch = getchar_unlocked());
	for (; '0' <= ch && ch <= '9'; ch = getchar_unlocked())
		v = (v << 3ll) + (v << 1ll) + (ch & 15ll);
}

int N, M, Q, T, L, R, C, K, A;
ll B;

struct node {
	node *left, *right;
	int S, E;
	bool hasmx;
	ll val, pv, pmx;
	node(int _s, int _e) : S(_s), E(_e), hasmx(0), val(0), pv(0), pmx(LLONG_MIN) {
		if (S == E) return;
		int M = (S + E) >> 1;
		left = new node(S, M);
		right = new node(M + 1, E);
	}
	void add_prop(bool t, ll x) {
		if (t == 0) {
			pv += x;
			if (hasmx) pmx += x;
		} else {
			pmx = max(pmx, x);
			hasmx = 1;
		}
	}
	void prop() {
		if (S == E) return;
		left->val += pv;
		right->val += pv;
		left->add_prop(0, pv);
		right->add_prop(0, pv);
		pv = 0;
		if (hasmx) {
			left->val = max(left->val, pmx);
			right->val = max(right->val, pmx);
			left->add_prop(1, pmx);
			right->add_prop(1, pmx);
			pmx = LLONG_MIN;
		} else assert(pmx == LLONG_MIN);
		hasmx = 0;
	}
	void add(int l, int r, ll v) {
		if (l > E || r < S) return;
		if (l <= S && E <= r) {
			add_prop(0, v);
			val += v;
			return;
		}
		prop();
		left->add(l, r, v);
		right->add(l, r, v);
	}
	ll qry(int p) {
		if (S == E) return val;
		int M = (S + E) >> 1;
		prop();
		if (p <= M) return left->qry(p);
		else return right->qry(p);
	}
} *root;

main() {
	read(N);
	read(M);
	read(Q);
	root = new node(1, N);
	for (int i = 1; i <= Q; i++) {
		read(T);
		if (T == 1) {
			read(L);
			read(R);
			read(C);
			read(K);
			root->add(L, R, K);
		} else if (T == 2) {
			read(L);
			read(R);
			read(K);
			root->add(L, R, -K);
			root->val = max(0ll, root->val);
			root->add_prop(1, 0);
		} else {
			read(A);
			read(B);
			printf("%d\n", (root->qry(A) >= B ? 1 : 0));
		}
	}
}

Compilation message

foodcourt.cpp:103:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  103 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 8432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 397 ms 28528 KB Output is correct
2 Correct 278 ms 24676 KB Output is correct
3 Correct 378 ms 31712 KB Output is correct
4 Correct 317 ms 31300 KB Output is correct
5 Correct 293 ms 23776 KB Output is correct
6 Correct 404 ms 31664 KB Output is correct
7 Correct 28 ms 424 KB Output is correct
8 Correct 35 ms 332 KB Output is correct
9 Correct 413 ms 31828 KB Output is correct
10 Correct 347 ms 31772 KB Output is correct
11 Correct 388 ms 31584 KB Output is correct
12 Correct 467 ms 31720 KB Output is correct
13 Correct 472 ms 31672 KB Output is correct
14 Correct 452 ms 31732 KB Output is correct
15 Correct 415 ms 31700 KB Output is correct
16 Correct 426 ms 31776 KB Output is correct
17 Correct 418 ms 31596 KB Output is correct
18 Correct 413 ms 31668 KB Output is correct
19 Correct 404 ms 31692 KB Output is correct
20 Correct 404 ms 31740 KB Output is correct
21 Correct 400 ms 31624 KB Output is correct
22 Correct 409 ms 31696 KB Output is correct
23 Correct 425 ms 31624 KB Output is correct
24 Correct 447 ms 31676 KB Output is correct
25 Correct 254 ms 24556 KB Output is correct
26 Correct 271 ms 31740 KB Output is correct
27 Correct 240 ms 31616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 8160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -