Submission #1314325

#TimeUsernameProblemLanguageResultExecution timeMemory
1314325arman.khachatryanGift (IZhO18_nicegift)C++20
0 / 100
87 ms13160 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];
    }
    if(a[0]%k==0){
        cout<<n/k-1+k+n%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<k+n%k; j++){
            cout<<a[0]/k<<" ";
            queue<int> dq=q;
            while(!dq.empty()){
                cout<<dq.front()<<" ";
                dq.pop();
            }
            cout<<'\n';
            int t=q.front();
            q.pop();
            if(t+k<=n){
                q.push(t+k);
            }else{
                q.push(t-n%k);
            }
        }
    }else if(n%k==0){
        cout<<n/k<<'\n';
        for(int j=1; j<=n/k; j++){
            cout<<a[0]<<" ";
            for(int i=j*k-k+1; i<=j*k; i++){
                cout<<i<<" ";
            }
            cout<<'\n';
        }
    }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...