Submission #91896

# Submission time Handle Problem Language Result Execution time Memory
91896 2018-12-31T10:55:40 Z emil_physmath Gift (IZhO18_nicegift) C++17
0 / 100
2000 ms 4220 KB
#include <iostream>
#include <stdio.h>
using namespace std;
const int MAXN=1000005;

int a[MAXN], ansL[MAXN];

int main()
{
	int n, k;
	cin>>n>>k;
	for (int i=0; i<n; i++)
		cin>>a[i];
	if ((n*a[0])%k)
	{
		cout<<"-1\n";
		return 0;
	}
	int l=1, r=k, l_i=1, r_i=1;
	while (r_i<=a[0])
	{
		ansL[l]++;
		l=r+1;
		l_i=r_i;
		if (l>n)
		{
			l%=n;
			l_i++;
		}
		if (l+k-1<=n)
		{
			r=l+k-1;
			r_i=l_i;
		}
		else
		{
			r=(l+k-1)%n;
			r_i=l_i+1;
		}
	}
	int op=0;
	for (int curL=1; curL<=n; curL++)
		if (ansL[curL])
			op++;
	cout<<op<<'\n';
	for (int curL=1; curL<=n; curL++)
	{
		if (!ansL[curL]) continue;
		int tempK=k, i=curL;
		printf("%d ", ansL[curL]);
		while (tempK--)
		{
			printf("%d ", i);
			i++;
			if (i>n) i%=n;
		}
		printf("\n");
	}

	char I;
	cin >> I;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2045 ms 4220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -