Submission #1085802

# Submission time Handle Problem Language Result Execution time Memory
1085802 2024-09-08T17:59:06 Z mar Kpart (eJOI21_kpart) C++14
0 / 100
2000 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000009;
typedef long long ll;
bitset<maxn>bs;
int a[maxn];
int can[maxn];

int main(){
    ll t; cin >> t;
    
    while(t--){
        ll n; cin >> n;
        for(int i=0; i<n; i++) cin>>a[i];
        
        for(int i = 2; i <= n; i++){
            if(can[i])continue;
            bool ok = false;
               
            for(int j = 0; j+i-1<n; j++){
                bs = 0;   
                bs[a[j]] = 1;
                ll sum = a[j];
                for(int k=j+1; k<j+i; k++){
                    bs|=(bs << a[k]);
                    sum += a[k];
                }
                
                if(sum % 2 == 0 && (bs[sum/2]))continue;
                ok = true;
                break;
            }
            if(!ok){
                can[i] = 1;
                for(int j = i; j <= n; j += i) can[j] = 1;
            }
           
        }
        vector<ll>ans;
        for(int i = 2; i <= n; i++) {
            if(can[i])ans.push_back(i);
        }
        
        cout << ans.size()<<" ";
        for(auto i: ans) cout<<i<<" ";
        cout<<endl;
    }
        
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 569 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -