제출 #378754

#제출 시각아이디문제언어결과실행 시간메모리
378754wiwihoGift (IZhO18_nicegift)C++14
19 / 100
371 ms17644 KiB
#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

typedef long long ll;

using pll = pair<ll, ll>;
using pii = pair<int, int>;

const ll MAX = 1LL << 60;

ostream& operator<<(ostream& o, pll p){
    return o << '(' << p.F << ',' << p.S << ')';
}

ll iceil(ll a, ll b){
    return (a + b - 1) / b;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;

    ll a = 0;
    for(int i = 1; i <= n; i++){
        ll t;
        cin >> t;
        if(i != 1) assert(a == t);
        a = t;
    }

    ll g = __gcd(n, k);
    if(a * n % k || n * k / g > 3000000){
        cout << "-1\n";
        return 0;
    }

    ll t = k / g;
    ll v = a / t;
    cout << n / g << "\n";
    int now = 0;
    for(int i = 0; i < n / g; i++){
        cout << v << " ";
        for(int j = 0; j < k; j++){
            cout << 1 + now % n << " ";
            now++;
        }
        cout << "\n";
    }

    return 0;
}
#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...