답안 #421844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
421844 2021-06-09T12:56:15 Z pavement 푸드 코트 (JOI21_foodcourt) C++17
0 / 100
1000 ms 61536 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;

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

struct node {
	node *left, *right;
	int S, E;
	ll val, pv;
	vector<pair<bool, ll> > vec;
	node(int _s, int _e) : S(_s), E(_e), val(0), pv(0) {
		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) {
			if (vec.empty()) vec.eb(t, x);
			else if (vec.back().first == 0) vec.back().second += x;
			else vec.back().second += x, pv += x;
		} else {
			if (vec.empty()) vec.eb(t, x);
			else if (vec.back().first == 1) vec.back().second = max(vec.back().second, x);
			else vec.eb(t, x);
		}
		assert(vec.size() <= 2);
	}
	void prop() {
		if (S == E) return;
		left->val += pv;
		right->val += pv;
		left->add_prop(0, pv);
		right->add_prop(0, pv);
		pv = 0;
		assert(vec.size() <= 2);
		if (vec.size() == 2) assert(vec[0].first == 0 && vec[1].first == 1);
		for (auto [t, x] : vec) {
			if (t == 0) {
				left->val += x;
				right->val += x;
			} else {
				left->val = max(left->val, x);
				right->val = max(right->val, x);
			}
			left->add_prop(t, x);
			right->add_prop(t, x);
		}
		vec.clear();
	}
	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() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M >> Q;
	root = new node(1, N);
	for (int i = 1; i <= Q; i++) {
		cin >> T;
		if (T == 1) {
			cin >> L >> R >> C >> K;
			root->add(L, R, K);
		} else if (T == 2) {
			cin >> L >> R >> K;
			root->add(L, R, -K);
			root->val = max(0ll, root->val);
			root->add_prop(1, 0);
		} else {
			cin >> A >> B;
			cout << (root->qry(A) >= B ? 1 : 0) << '\n';
		}
	}
}

Compilation message

foodcourt.cpp:96:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   96 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 184 ms 16200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 862 ms 55340 KB Output is correct
2 Correct 682 ms 48084 KB Output is correct
3 Correct 946 ms 61536 KB Output is correct
4 Correct 757 ms 59604 KB Output is correct
5 Correct 748 ms 46180 KB Output is correct
6 Execution timed out 1037 ms 61324 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 140 ms 13792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -