Submission #537619

# Submission time Handle Problem Language Result Execution time Memory
537619 2022-03-15T09:56:05 Z Hydroxic_Acid Kpart (eJOI21_kpart) C++17
0 / 100
1 ms 212 KB
#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
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -