이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ff first
#define ss second
const int N = 3e5+5;
int T, n;
int main(){
cin >> T;
while(T--){
cin >> n;
vector <int> a(n+1);
int s = 0;
for(int i = 1; i <= n; i++){
cin >> a[i];
s += a[i];
}
vector <bool> vis(n+1,0);
vector <int> dp(s+1,0);
for(int i = 1; i <= n; i++){
dp[a[i]] = i;
for(int j = a[i]; j <= s; j++){
dp[j] = max(dp[j],dp[j-a[i]]);
}
int s = 0;
for(int j = i; j >= 1; j--){
s += a[j];
if(dp[s/2] < j or s % 2 == 1) vis[i-j+1] = 1;
}
}
vector <int> v;
int cnt = 0;
for(int i = 1; i <= n; i++){
if(vis[i] == 0){
cnt++;
v.push_back(i);
}
}
cout << cnt << ' ';
for(auto i : v){
cout << i << " ";
}
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... |