#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;
int 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;
}
}
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 ", numRep*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 |
Incorrect |
146 ms |
16884 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 |
- |