이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;
int f(int x, int n){
if (x > n){
x %= n;
}
return x;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int n, k;
cin >> n >> k;
vi a(n);
for (auto& i : a){
cin >> i;
}
if (a[0] %k && n%k) return cout << "-1\n", 0;
if (n%k == 0){
cout << n/k << '\n';
for (int i = 1; i <= n; i += k){
cout << a[0] << ' ';
for (int j = i; j < i+k; ++j)
cout << j << ' ';
cout << '\n';
}
return 0;
}
int s = a[0]/k;
cout << n << '\n';
for (int i = 1; i <= n; ++i){
cout << s << ' ';
for (int j = i; j < i+k; ++j){
cout << f(j, n) << ' ';
a[f(j,n)-1] -=s;
}
cout << '\n';
}
for (int i = 0; i < n; ++i)
if (a[i] > 0)
throw SIGSEGV;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |