이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int T, N, K;
int arr[1005];
int need[1005];
signed main(){
cin >> T;
for(int i = 0; i < T; i++){
cin >> N >> K;
for(int j = 0; j < N; j++) cin >> arr[j];
vector<int> ans;
memset(need, 0, sizeof(need));
for(int j = 2; j <= K; j++){
if(need[j]){
ans.push_back(j); continue;
}
int summ = 0;
for(int k = 0; k <= j - 1; k++) summ += arr[k];
bool yes = true;
for(int k = j - 1; k < N; k++){
if(k >= j) summ -= arr[k - j] - arr[k];
if(summ % 2 != 0){
yes = false; break;
}
vector<int> v;
for(int l = k - j + 1; l <= k; l++){
bool b = false;
for(int m = 0; m < (int)v.size(); m++){
if(v[m] + arr[l] == summ / 2){
b = true; break;
}
if(v[m] + arr[l] < summ / 2){
v.push_back(v[m] + arr[l]);
}
}
if(b) break;
if(l == k) yes = false;
}
if(!yes) break;
}
if(yes){
ans.push_back(j);
for(int k = j + j; k < N; k+=j){
need[k] = 1;
}
}
}
cout << (int)ans.size() << " ";
for(int j = 0; j < (int)ans.size(); j++) cout << ans[j] << " ";
cout << "\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |