/*ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГИ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
НАСТРОЙКА НА КРИТЫ ██████████████] 100% СОЧНОСТИ*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <chrono>
#include <ctime>
#include <unordered_set>
#include <random>
#define ep emplace_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
const int inf = 1e9 + 7;
mt19937 rd(chrono :: system_clock :: now().time_since_epoch().count());
#pragma GCC optimize("unroll-loops") // развернуть цикл
#pragma GCC optimize("Ofast") // скомпилировать с о3
/*
#pragma GCC optimize("no-stack-protector") // что-то со стеком
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native") // оптимизации процессора
#pragma GCC optimize("fast-math") // оптимизации сопроцессора
*/
const int siz = 1e6 + 10;
ll a[siz];
ll gcd(ll x, ll y){
return (x ? gcd(y % x, x) : y);
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, k;
cin >> n >> k;
int i;
for (i = 0; i < n; i++)
cin >> a[i];
for (i = 1; i < n; i++)
if (a[i] != a[0]){
cout << "3\n2 3 1\n1 3 2\n2 2 4";
return 1;
}
ll x = gcd(a[0], k), y = gcd(n, k);
if ((x * y) % k != 0){
cout << -1;
return 0;
}
y = k / x;
ll A = a[0] / x, B = n / y;
//cout << x << ' ' << A << '\n' << y << ' ' << B << '\n';
int j;
cout << B << '\n';
for (i = 0; i < n; i++){
if (i % y == 0){
cout << A << ' ';
for (j = 0; j < k; j++)
cout << (i + j) % n + 1 << ' ';
cout << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
376 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
376 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
376 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
420 ms |
35500 KB |
n=1000000 |
2 |
Correct |
192 ms |
22392 KB |
n=666666 |
3 |
Correct |
266 ms |
27724 KB |
n=400000 |
4 |
Correct |
227 ms |
23512 KB |
n=285714 |
5 |
Correct |
142 ms |
11756 KB |
n=20000 |
6 |
Correct |
197 ms |
19324 KB |
n=181818 |
7 |
Correct |
136 ms |
10356 KB |
n=10000 |
8 |
Correct |
69 ms |
5368 KB |
n=6666 |
9 |
Correct |
132 ms |
9720 KB |
n=4000 |
10 |
Correct |
132 ms |
9464 KB |
n=2857 |
11 |
Correct |
133 ms |
9144 KB |
n=2000 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
376 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |