답안 #1107355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107355 2024-11-01T06:50:47 Z vjudge1 Kpart (eJOI21_kpart) C++17
30 / 100
2000 ms 504 KB
/**
 *    hello
 *    author:  N29
 *    created: 2024-11-01 10:28:15
**/
#include <string>
#include <bits/functexcept.h>
#include <iosfwd>
#include <bits/cxxabi_forced.h>
#include <bits/functional_hash.h>

#pragma push_macro("__SIZEOF_LONG__")
#pragma push_macro("__cplusplus")
#define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
#define unsigned unsigned long
#define __cplusplus 201102L

#define __builtin_popcountl __builtin_popcountll
#define __builtin_ctzl __builtin_ctzll

#include <bitset>

#pragma pop_macro("__cplusplus")
#pragma pop_macro("__SIZEOF_LONG__")
#undef unsigned
#undef __builtin_popcountl
#undef __builtin_ctzl
#include<bits/stdc++.h>
using namespace std;
// #ifndef BADGNU
#pragma GCC target("sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #endif
#pragma GCC optimize("O3,Ofast,unroll-loops,fast-math")
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
#define ll long long
// #define int ll
#define ld long double
#define y1 cheza
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
// template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=5e4+100;
const int M=5001;
const int B=447;
const int mod=998244353;
const ll INF=1e18;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-6;
int n;
int a[N];
int pref[N];
bitset<N> dp;
bool bad[N];
void test(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        bad[i]=0;
    }
    for(int i=1;i<=n;i++){
        pref[i]=pref[i-1]+a[i];
    }
    for(int i=1;i<=n;i++){
        dp.reset();
        dp[0]=1;
        for(int j=i;j<=n;j++){
            dp=(dp|dp<<a[j]);
            if((pref[j]-pref[i-1])&1ll){
                bad[(j-i+1)]=1;
                continue;
            }
            if(!dp[(pref[j]-pref[i-1])>>1ll]){
                bad[(j-i+1)]=1;
            }
        }
    }
    vector<int>v;
    for(int i=1;i<=n;i++){
        if(bad[i])continue;
        v.push_back(i);
    }
    
    cout<<v.size()<<' ';
    for(auto i:v){
        cout<<i<<' ';
    }
    cout<<'\n';
    
}



/*

*/
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    int t2=1;
    cin>>t2;
    for(int i=1;i<=t2;i++){
        test();
    }
}

Compilation message

Main.cpp:14: warning: "__SIZEOF_LONG__" redefined
   14 | #define __SIZEOF_LONG__ __SIZEOF_LONG_LONG__
      | 
<built-in>: note: this is the location of the previous definition
Main.cpp:16: warning: "__cplusplus" redefined
   16 | #define __cplusplus 201102L
      | 
<built-in>: note: this is the location of the previous definition
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 336 KB Output is correct
2 Correct 104 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 464 ms 484 KB Output is correct
2 Correct 1293 ms 500 KB Output is correct
3 Correct 1374 ms 504 KB Output is correct
4 Execution timed out 2045 ms 484 KB Time limit exceeded
5 Halted 0 ms 0 KB -