Submission #91904

# Submission time Handle Problem Language Result Execution time Memory
91904 2018-12-31T11:18:02 Z emil_physmath Gift (IZhO18_nicegift) C++17
19 / 100
283 ms 30188 KB
#include <iostream>
#include <stdio.h>
using namespace std;
const long long MAXN=1000005;

long long a[MAXN], ansL[MAXN];

int main()
{
	long long n, k;
	cin>>n>>k;
	for (long long i=0; i<n; i++)
		scanf("%lld", a+i);
	if ((n*a[0])%k)
	{
		cout<<"-1\n";
		return 0;
	}
	long long l=1, r=k, l_i=1, r_i=1;
	long long numRep=1;
	while (r_i<=a[0])
	{
		if (l==1 && l_i!=1)
		{
			numRep=a[0]/(l_i-1);
			break;
		}
		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;
		}
	}
	long long op=0;
	for (long long curL=1; curL<=n; curL++)
		if (ansL[curL])
			op++;
	cout<<op<<'\n';
	for (long long curL=1; curL<=n; curL++)
	{
		if (!ansL[curL]) continue;
		long long tempK=k, i=curL;
		printf("%lld ", numRep*ansL[curL]);
		while (tempK--)
		{
			printf("%lld ", i);
			i++;
			if (i>n) i%=n;
		}
		printf("\n");
	}

	char I;
	cin >> I;
	return 0;
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", a+i);
   ~~~~~^~~~~~~~~~~~~
# 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 Correct 283 ms 30188 KB n=1000000
2 Correct 183 ms 27768 KB n=666666
3 Correct 105 ms 15864 KB n=400000
4 Correct 244 ms 25720 KB n=285714
5 Correct 6 ms 1016 KB n=20000
6 Correct 214 ms 20724 KB n=181818
7 Correct 4 ms 764 KB n=10000
8 Correct 28 ms 2168 KB n=6666
9 Correct 3 ms 504 KB n=4000
10 Correct 154 ms 9704 KB n=2857
11 Correct 2 ms 380 KB n=2000
# 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 -