Submission #1314593

#TimeUsernameProblemLanguageResultExecution timeMemory
1314593arman.khachatryanGift (IZhO18_nicegift)C++20
0 / 100
87 ms13172 KiB
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
int a[N];
int main() {
    int n, k;
    cin>>n>>k;
    int s=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int g;
    for(int i=1; i<=k; i++){
        if(n%i==0 && k%i==0){
            g=i;
        }
    }
    if((n*a[0])%k==0){
        cout<<n/k-1+a[0]*(k+n%k)/k<<'\n';
        for(int j=1; j<=n/k-1; j++){
            cout<<a[0]<<" ";
            for(int i=j*k-k+1; i<=j*k; i++){
                cout<<i<<" ";
            }
            cout<<'\n';
        }
        queue<int> q;
        for(int i=(n/k-1)*k+1; i<=n-n%k; i++){
            q.push(i);
        }
        for(int j=0; j<a[0]*(k+n%k)/k; j++){
            cout<<1<<" ";
            queue<int> dq=q;
            while(!dq.empty()){
                cout<<dq.front()<<" ";
                dq.pop();
            }
            cout<<'\n';
            int f=g;
            while(f--){
                int t=q.front();
                q.pop();
                if(t+k<=n){
                    q.push(t+k);
                }else{
                    q.push(t-n%k);
                }
            }
        }
    }else{
        cout<<-1;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...