Submission #512582

# Submission time Handle Problem Language Result Execution time Memory
512582 2022-01-16T13:25:39 Z sidon Teams (CEOI11_tea) C++17
0 / 100
386 ms 38620 KB
#include <bits/stdc++.h>
using namespace std;

const int Z = 1e6+1, oo = 2e9;

int N, A[Z], S[Z];
array<int, 3> F[Z];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);

	cin >> N;

	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		S[i] = i;
		F[i + 1] = {-oo};
	}

	sort(S, S + N + 1, [&](int i, int j) {
		return A[i] < A[j];
	});

	for(int i = 1; i <= N; i++) {
		array<int, 3> best = {-oo};

		for(int j = i - A[S[i]] + 1; j >= 1; j -= j&-j)
			best = max(best, F[j]);

		++best[0];
		swap(best[1], best[2]);
		best[1] = i;

		for(int j = i + 1; j <= N+1; j += j&-j) 
			F[j] = max(F[j], best);
	}

	vector<vector<int>> res = {{}};
	int curr = F[N+1][2];

	for(int i = N + 1; --i; ) {
		if(curr == i) {
			res.push_back({});
			curr = F[i+1][2];
		}
		res.back().push_back(S[i]);
	}

	cout << size(res) << '\n';
	for(auto &V : res) {
		cout << size(V);
		for(auto &i : V) cout << ' ' << i;
		cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 324 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 500 KB Output is correct
2 Incorrect 1 ms 460 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 3248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 3500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 248 ms 27364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 353 ms 36684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 386 ms 38620 KB Output isn't correct
2 Halted 0 ms 0 KB -