#include <bits/stdc++.h>
#define int long long
#define float double
#define pb push_back
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
/// Benzema is the best player in the world
const int N = 1e6 + 6;
const int M = 1e3 + 3;
const int mod = 1e9 + 7;
const int inf = 1e9;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const int LOG = 25;
int n, k, a[N];
vector<int> ans, v;
bool check() {
if (v.size() % k) return 0;
bool ok = 1;
for(int i = 0; i < v.size(); i += k) {
ok &= (begin(v) + i, begin(v) + i + k) == (begin(v), begin(v) + k);
}
return ok;
}
main() {
IOS
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) {
for(int j = i; j <= n; j++) {
v.push_back(i);
if (check() && v.size() > ans.size()) ans = v;
}
}
cout << ans.size() / k << '\n';
for(int i = 0; i < ans.size() / k; i++) cout << ans[i] << ' ';
}
Compilation message
Main.cpp: In function 'bool check()':
Main.cpp:25:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int i = 0; i < v.size(); i += k) {
| ~~^~~~~~~~~~
Main.cpp: At global scope:
Main.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
31 | main() {
| ^~~~
Main.cpp: In function 'int main()':
Main.cpp:42:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
42 | for(int i = 0; i < ans.size() / k; i++) cout << ans[i] << ' ';
| ~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Sequence doesn't repeat k times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Sequence doesn't repeat k times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Sequence doesn't repeat k times |
2 |
Halted |
0 ms |
0 KB |
- |