답안 #421736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
421736 2021-06-09T11:29:47 Z pavement 푸드 코트 (JOI21_foodcourt) C++17
0 / 100
469 ms 524292 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, B;

struct node {
	node *left, *right;
	int S, E, pos;
	vector<pair<bool, int> > val;
	node(int _s, int _e) : S(_s), E(_e), pos(0) {
		if (S == E) return;
		int M = (S + E) >> 1;
		left = new node(S, M);
		right = new node(M + 1, E);
	}
	void prop() {
		if (S == E) return;
		for (; pos < val.size(); pos++) {
			auto [tmp1, tmp2] = val[pos];
			left->val.eb(tmp1, tmp2);
			right->val.eb(tmp1, tmp2);
		}
	}
	void upd(int l, int r, int v, bool t = 0) {
		if (l > E || r < S) return;
		if (l <= S && E <= r) {
			val.eb(t, v);
			return;
		}
		prop();
		left->upd(l, r, v, t);
		right->upd(l, r, v, t);
	}
	int qry(int p) {
		if (S == E) {
			int tmp = 0;
			for (; pos < val.size(); pos++) {
				auto [tmp1, tmp2] = val[pos];
				if (tmp1) tmp = max(0ll, tmp);
				else tmp += tmp2;
			}
			val.eb(0, tmp);
			return tmp;
		}
		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->upd(L, R, K);
		} else if (T == 2) {
			cin >> L >> R >> K;
			root->upd(L, R, -K);
			root->upd(L, R, 0, 1);
		} else {
			cin >> A >> B;
			cout << (root->qry(A) >= B ? 1 : 0) << '\n';
		}
	}
}

Compilation message

foodcourt.cpp: In member function 'void node::prop()':
foodcourt.cpp:42:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<bool, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (; pos < val.size(); pos++) {
      |          ~~~~^~~~~~~~~~~~
foodcourt.cpp: In member function 'long long int node::qry(long long int)':
foodcourt.cpp:61:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<bool, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |    for (; pos < val.size(); pos++) {
      |           ~~~~^~~~~~~~~~~~
foodcourt.cpp: At global scope:
foodcourt.cpp:76:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   76 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 26620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 26620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 469 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 435 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 26620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 463 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 26620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 26620 KB Output isn't correct
2 Halted 0 ms 0 KB -