#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
const int mxn = 1e5 + 5, mxv = 5e4 + 5;
int a[mxn + 1], n;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tt; cin >> tt;
while(tt--){
cin >> n;
vt<bool>ok(n + 1, 1);
for(int i = 1; i <= n; i++)cin >> a[i];
bitset<mxv>bs;
for(int i = 1; i <= n; i++){
bs.reset(); bs[0] = 1;
int sm = 0;
for(int j = i; j <= n; j++){
bs = bs | (bs << a[j]);sm += a[j];
if(sm & 1 || !bs[sm / 2]){
ok[j - i + 1] = 0;
}
}
}
vt<int>res;
for(int i = 1; i <= n; i++){
if(ok[i])res.pb(i);
}
cout << sz(res) << " ";
for(auto i: res)cout << i << " ";
cout << "\n";
}
return(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
340 KB |
Output is correct |
2 |
Correct |
149 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
645 ms |
340 KB |
Output is correct |
2 |
Correct |
1691 ms |
460 KB |
Output is correct |
3 |
Correct |
1982 ms |
472 KB |
Output is correct |
4 |
Execution timed out |
2061 ms |
372 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |