제출 #1211724

#제출 시각아이디문제언어결과실행 시간메모리
1211724adhityamvGift (IZhO18_nicegift)C++20
19 / 100
142 ms22560 KiB
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#include <stack>
using namespace std;
#define int long long
#define mp make_pair
#define fi first
#define pii pair<int,int>
#define se second
const int INF=1000000000000000000;
//const int INF=1e9;
const int N=1000000;
const int M=998244353;
const int ln=20;
template<typename T>
std::ostream& operator<< (std::ostream& os,pair<T,T> p){
    return os << p.fi << "," << p.se << " ";
}
void solve(){
    int n,k;
    cin >> n >> k;
    int g=1;
    for(int i=1;i<=n;i++){
        if(n%i==0 && k%i==0) g=i;
    }
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        assert(a[i]==a[0]);
    }
    if(a[0]%(k/g)!=0){
        cout << -1 << "\n";
        return;
    }
    int x=a[0]/(k/g);
    cout << n/g << "\n";
    for(int i=0;i<n/g;i++){
        cout << x << " ";
        for(int j=0;j<k;j++){
            cout << (i*(g)+j)%n+1LL << " ";
        }
        cout << "\n";
    }
}
signed main(){
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t;
    //cin >> t;
    t=1;
    while(t--) solve();
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
}
#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...