Submission #552884

# Submission time Handle Problem Language Result Execution time Memory
552884 2022-04-24T09:08:28 Z blue Teams (CEOI11_tea) C++17
0 / 100
262 ms 105256 KB
#include <iostream>
#include <vector>
using namespace std;

using vi = vector<int>;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int N;
	cin >> N;

	vi lst[1+N];
	for(int i = 1; i <= N; i++)
	{
		int a;
		cin >> a;
		lst[a].push_back(i);
	}

	vi A(1, 0);
	vi I(1, 0);
	for(int i = N; i >= 1; i--)
	{
		for(int x : lst[i])
		{
			A.push_back(i);
			I.push_back(x);
		}
	}

	vi maxteams(1+N);
	vi sizelim(1+N, 5'000'000);
	vi prev(1+N, 0);

	maxteams[0] = sizelim[0] = 0;

	vi occ[1+N+1];

	if(A[1] + 1 <= N+1)
		occ[A[1] + 1].push_back(1);

	for(int i = A[1]+1; i <= N; i++)
	{
		if(A[i] + i <= N+1)
			occ[A[i] + i].push_back(i);
	}

	for(int i = A[1]; i <= N; i++)
	{
		// cerr << "i = " << i << '\n';
		// if(i < A[1])
		// {
		// 	maxteams[i] = sizelim[i] = prev[i] = -1;
		// 	continue;
		// }

		maxteams[i] = 0;


		for(int j : occ[i+1])
		{
			if(j > i) continue;

			if(maxteams[j-1] != maxteams[i-1]) continue;

			int currsize = max(sizelim[j-1], i-j+1);
			if(maxteams[i] == 0 || sizelim[i] > currsize)
			{
				maxteams[i] = maxteams[i-1] + 1;
				sizelim[i] = currsize;
				prev[i] = j-1;
			}
		}

		// cerr << "phase 1 : " << maxteams[i] << '\n';

		if(maxteams[i] == 0)
		{
			maxteams[i] = maxteams[i-1];

			// for(int j = 1; j <= i; j++) if(A[j] <= i-j+1)
			for(int j : occ[i+1])
			{
				if(A[j] > i-j+1) continue;
				if(j > i) continue;

				// cerr << i << " <- " << j << ' ' << A[j] << ' ' << i-j+1 << '\n';

				if(maxteams[j-1] != maxteams[i] - 1) continue;

				int currsize = max(sizelim[j-1], i-j+1);
				if(sizelim[i] > currsize)
				{
					sizelim[i] = currsize;
					prev[i] = j-1;
				}
			}
		}
	}

	// for(int i = 1; i <= N; i++) cerr << A[i] << ' ' << I[i] << " : " << maxteams[i] << ' ' << sizelim[i] << ' ' << prev[i] << '\n';


	int ci = N;

	cout << maxteams[N] << '\n';
	for(int z = 1; z <= maxteams[N]; z++)
	{
		// cerr << "ci = " << ci << '\n';
		cout << ci - prev[ci] << ' ';
		for(int q = prev[ci]+1; q <= ci; q++)
			cout << I[q] << ' ';
		cout << '\n';

		ci = prev[ci];
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 20]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 100]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 200]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 724 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 4999]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 724 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 5000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 7900 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 80005]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 9292 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 90003]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 82768 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 750013]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 262 ms 105256 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 1000000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 227 ms 82616 KB Integer parameter [name=s_i] equals to 0, violates the range [1, 1000000]
2 Halted 0 ms 0 KB -