답안 #815219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815219 2023-08-08T13:17:15 Z acatmeowmeow 사다리꼴 (balkan11_trapezoid) C++11
35 / 100
84 ms 7284 KB
#include <bits/stdc++.h>

using namespace std;

//#define int long long 

const int N = 1e5, modulo = 30013;
int n, a[N + 5], b[N + 5], c[N + 5], d[N + 5];
pair<int, int> indx[N + 5], tree[2*N + 5], dp[N + 5];
vector<int> mp;

pair<int, int> combine(pair<int, int>&f, pair<int, int>&se) {
	if (f.first == se.first) return {f.first, (f.second + se.second) % modulo};
	else return f > se ? f : se;
}

void update(int k, pair<int, int> x) {
	for (; k <= 2*n; k += k&-k) tree[k] = combine(tree[k], x);
}

pair<int, int> query(int k) {
	pair<int, int> ans = {0, 0};
	for (; k; k -= k&-k) ans = combine(ans, tree[k]);
	return ans;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];

	for (int i = 1; i <= 2*n; i += 2) indx[i] = {(i + 1)/2, 0}, indx[i + 1] = {(i + 1)/2, 1};
	sort(indx + 1, indx + 2*n + 1, [&](pair<int, int>&x, pair<int, int>&y) {
			int f = x.second == 0 ? a[x.first] : b[x.first];
			int se = y.second == 0 ? a[y.first] : b[y.first];
			return f < se;
	});

	for (int i = 1; i <= n; i++) mp.push_back(c[i]), mp.push_back(d[i]);
	sort(mp.begin(), mp.end());
	mp.erase(unique(mp.begin(), mp.end()), mp.end());
	auto getIndex = [&](int p) { return lower_bound(mp.begin(), mp.end(), p) - mp.begin() + 1; };

	for (int i = 1; i <= 2*n; i++) {
		int index = indx[i].first, type = indx[i].second;
		if (!type) {
			int Y = getIndex(c[index]);
			pair<int, int> res = query(Y);
			if (!res.first) dp[index] = {1, 1};
			else dp[index] = {res.first + 1, res.second};
		} else {
			int Y = getIndex(d[index]);
			update(Y, dp[index]);
		}
	}
	int mx = 0, total = 0;
	for (int i = 1; i <= n; i++) {
		if (mx < dp[i].first) mx = dp[i].first, total = dp[i].second;
		else if (mx == dp[i].first) total += dp[i].second;
	}
	cout << mx << " "<< total << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Partially correct 1 ms 384 KB Partially correct
4 Partially correct 1 ms 340 KB Partially correct
5 Correct 2 ms 468 KB Output is correct
6 Partially correct 2 ms 596 KB Partially correct
7 Partially correct 3 ms 720 KB Partially correct
8 Partially correct 6 ms 736 KB Partially correct
9 Partially correct 8 ms 1236 KB Partially correct
10 Partially correct 21 ms 2216 KB Partially correct
11 Partially correct 27 ms 2708 KB Partially correct
12 Partially correct 50 ms 4864 KB Partially correct
13 Incorrect 64 ms 5324 KB Output isn't correct
14 Incorrect 61 ms 5596 KB Output isn't correct
15 Incorrect 71 ms 5904 KB Output isn't correct
16 Incorrect 82 ms 6108 KB Output isn't correct
17 Incorrect 64 ms 6476 KB Output isn't correct
18 Partially correct 65 ms 6632 KB Partially correct
19 Incorrect 65 ms 6984 KB Output isn't correct
20 Incorrect 84 ms 7284 KB Output isn't correct