Submission #54248

# Submission time Handle Problem Language Result Execution time Memory
54248 2018-07-02T22:05:50 Z baactree Pyramid Base (IOI08_pyramid_base) C++17
0 / 100
5000 ms 55140 KB
#include <bits/stdc++.h>
using namespace std;
int tree[1 << 21][2];
void update(int le, int ri, int val, int nodele, int noderi, int node) {
	if (le > noderi || ri < nodele)return;
	if (le <= nodele && noderi <= ri) {
		tree[node][0] += val;
		tree[node][1] += val;
		return;
	}
	int mid = (nodele + noderi) / 2;
	update(le, ri, val, nodele, mid, node * 2);
	update(le, ri, val, mid + 1, noderi, node * 2 + 1);
	tree[node][0] = min(tree[node * 2][0], tree[node * 2 + 1][0])+tree[node][1];
}
void init(int nodele, int noderi, int node) {
	if (nodele == noderi) {
		tree[node][0] = tree[node][1] = 0;
		return;
	}
	int mid = (nodele + noderi) / 2;
	init(nodele, mid, node * 2);
	init(mid + 1, noderi, node * 2 + 1);
}
int n, m, b, p;
vector<tuple<int, int, int> > vec[1000005];
bool possi(int k) {
	init(1, m - k + 1, 1);
	for (int i = 1; i <= n; i++) {
		for (auto v : vec[i]) {
			int y1, y2, c;
			tie(y1, y2, c) = v;
			if (c > 0) update(max(1, y1 - k + 1), min(m - k + 1, y2), c, 1, m - k + 1, 1);
		}
		if (i >= k) {
			for (auto v : vec[i - k]) {
				int y1, y2, c;
				tie(y1, y2, c) = v;
				if (c < 0) update(max(1, y1 - k + 1), min(m - k + 1, y2), c, 1, m - k + 1, 1);
			}
		}
		if (i >= k && tree[1][0] <= b) return true;
	}
	return false;
}
int main() {
	scanf("%d%d%d%d", &n, &m, &b, &p);
	for (int i = 0; i < p; i++) {
		int x1, y1, x2, y2, c;
		scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &c);
		vec[x1].emplace_back(y1, y2, b ? c : 1);
		vec[x2].emplace_back(y1, y2, b ? -c : -1);
	}
	int le, ri, ans, mid;
	le = 1;
	ri = m;
	ans = 0;
	while (le <= ri) {
		mid = (le + ri) / 2;
		if (possi(mid)) {
			ans = mid;
			le = mid + 1;
		}
		else ri = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

pyramid_base.cpp: In function 'int main()':
pyramid_base.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &n, &m, &b, &p);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
pyramid_base.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 23800 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 23800 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 23972 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 24172 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 25964 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 32108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 239 ms 40428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 40428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 247 ms 40428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 475 ms 40428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 948 ms 41660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 671 ms 41660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5035 ms 51032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5012 ms 55140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5020 ms 55140 KB Time limit exceeded
2 Halted 0 ms 0 KB -