Submission #684131

# Submission time Handle Problem Language Result Execution time Memory
684131 2023-01-20T13:43:12 Z Victor Kpart (eJOI21_kpart) C++17
30 / 100
2000 ms 364 KB
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize ("Ofast,inline") // O1 - O2 - O3 - Os - Ofast
// #pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define debug(x) cout<<#x<<" = "<<x<<endl

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;

const int INF = 1'000'000'007;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

    int tc,arr[1005],n,works[1005];
    bitset<50001> reach;
    cin>>tc;
    while(tc--) {
        memset(works,0,sizeof(works));
        cin>>n;
        rep(i,0,n) cin>>arr[i];
        rep(i,0,n) {
            reach.reset();
            reach[0]=1;
            int sum=0;
            rep(j,i,n) {
                sum+=arr[j];
                reach|=reach<<arr[j];
                if(sum%2==1||!reach[sum/2]) works[j-i]=1;
            }
        }
        vi ans;
        rep(i,0,n) if(!works[i]) ans.pb(i);
        cout<<sz(ans);
        trav(val,ans) cout<<' '<<val+1;
        cout<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 340 KB Output is correct
2 Correct 181 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 776 ms 340 KB Output is correct
2 Execution timed out 2029 ms 364 KB Time limit exceeded
3 Halted 0 ms 0 KB -